-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix loading of Subject/Issuer-Alt-Name extensions. (#144)
These were being treated specially and incorrectly when being loaded from encoded values. A given extension may not occur more than once in certificate or CRL, and hence this code could never be correct. Fixed the erroneous test for this too.
- Loading branch information
1 parent
b852b51
commit 617ca56
Showing
2 changed files
with
6 additions
and
27 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
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 |
---|---|---|
|
@@ -82,25 +82,23 @@ def test_resolve_extensions | |
[ "keyUsage", "keyCertSign, cRLSign", true ], | ||
[ "subjectKeyIdentifier", "hash", false ], | ||
[ "authorityKeyIdentifier", "keyid:always", false ], | ||
[ "subjectAltName", "email:[email protected]", false ], | ||
[ "subjectAltName", "DNS:jruby.org", false ], | ||
[ "subjectAltName", "email:[email protected], DNS:jruby.org", false ], | ||
] | ||
|
||
now = Time.now | ||
ca_cert = issue_cert(ca, rsa2048, 1, now, now + 3600, ca_exts, | ||
nil, nil, OpenSSL::Digest::SHA1.new) | ||
|
||
assert_equal 6, ca_cert.extensions.size | ||
assert_equal 5, ca_cert.extensions.size | ||
|
||
cert = OpenSSL::X509::Certificate.new ca_cert.to_der | ||
assert_equal 6, cert.extensions.size | ||
assert_equal 5, cert.extensions.size | ||
|
||
# Java 6/7 seems to maintain same order but Java 8 does definitely not : | ||
# TODO there must be something going on under - maybe not BC parsing ?!? | ||
if self.class.java6? || self.class.java7? | ||
assert_equal '97:39:9D:C3:FB:CD:BA:8F:54:0C:90:7B:46:3F:EA:D6:43:75:B1:CB', cert.extensions[2].value | ||
assert_equal 'email:[email protected]', cert.extensions[4].value | ||
assert_equal 'DNS:jruby.org', cert.extensions[5].value | ||
assert_equal 'email:[email protected], DNS:jruby.org', cert.extensions[4].value | ||
end | ||
|
||
exts = cert.extensions.dup | ||
|
@@ -118,10 +116,7 @@ def test_resolve_extensions | |
assert ! ext.critical? | ||
|
||
assert ext = exts.find { |e| e.oid == 'subjectAltName' }, "missing 'subjectAltName' among: #{exts.join(', ')}" | ||
assert_equal 'email:[email protected]', ext.value | ||
exts.delete(ext) | ||
assert ext = exts.find { |e| e.oid == 'subjectAltName' }, "missing 'subjectAltName' among: #{exts.join(', ')}" | ||
assert_equal 'DNS:jruby.org', ext.value | ||
assert_equal 'email:[email protected], DNS:jruby.org', ext.value | ||
end | ||
|
||
def test_extensions | ||
|
@@ -367,4 +362,4 @@ def test_cert_loading_regression | |
-----END RSA PRIVATE KEY----- | ||
_end_of_pem_ | ||
|
||
end | ||
end |