-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PUP-11935) Handle JRuby OpenSSL behavior
Starting with jruby-openssl 0.13.0[1] (which is included in JRuby >= 9.3.5.0), certificate signing raises an error when there is a discrepancy between the certificate and key. This behavior in JRuby differs from MRI OpenSSL. This commit adds a test for this JRuby-specific behavior and updates existing tests to skip when running on affected versions of JRuby. [1] jruby/jruby-openssl@4b2968b
- Loading branch information
1 parent
2fcd7c7
commit 760ec82
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe Puppet::SSL::CertificateSigner do | ||
include PuppetSpec::Files | ||
|
||
let(:wrong_key) { OpenSSL::PKey::RSA.new(512) } | ||
let(:client_cert) { cert_fixture('signed.pem') } | ||
|
||
# jruby-openssl >= 0.13.0 (JRuby >= 9.3.5.0) raises an error when signing a | ||
# certificate when there is a discrepancy between the certificate and key. | ||
it 'raises if client cert signature is invalid', if: Puppet::Util::Platform.jruby? && RUBY_VERSION.to_f >= 2.6 do | ||
expect { | ||
client_cert.sign(wrong_key, OpenSSL::Digest::SHA256.new) | ||
}.to raise_error(OpenSSL::X509::CertificateError, | ||
'invalid public key data') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters