forked from jruby/jruby-openssl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix subjectAltName parsing to always generate GeneralNames.
It now handles arbitrary lists of names and always produces a GeneralNames as required by the definition. Additionally, leading and trailing whitespace around separators and labels is properly removed. This fixes jruby#134.
- Loading branch information
1 parent
142c0a0
commit 32369c4
Showing
2 changed files
with
62 additions
and
43 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 |
---|---|---|
|
@@ -151,12 +151,38 @@ def test_subject_alt_name_sign_to_pem | |
end | ||
|
||
def test_subject_alt_name_sequence | ||
tests = [ | ||
{ | ||
:input => "email:[email protected],DNS:a.b.com,email:[email protected]", | ||
:output => "email:[email protected], DNS:a.b.com, email:[email protected]", | ||
:der => "0,\x06\x03U\x1D\x11\x04%0#\x81\v[email protected]\x82\aa.b.com\x81\v[email protected]", | ||
}, | ||
{ | ||
:input => "DNS:a.b.com, email:[email protected]", | ||
:der => "0\x1f\x06\x03U\x1d\x11\x04\x180\x16\x82\x07a.b.com\x81\x0b[email protected]", | ||
}, | ||
{ | ||
:input => "URI:https://a.b.com/, DNS:a.b.com", | ||
:der => "0$\x06\x03U\x1d\x11\x04\x1d0\x1b\x86\x10https://a.b.com/\x82\x07a.b.com", | ||
}, | ||
{ | ||
:input => "IP:1.2.3.4,IP: fe80::12:345:5678, email:[email protected], dirName: CN=John Doe\\,O=Acme", | ||
:output => "IP:1.2.3.4, IP:fe80:0:0:0:0:12:345:5678, email:[email protected], DirName:CN=John Doe,O=Acme", | ||
:der => "0T\x06\x03U\x1d\x11\x04M0K\x87\x04\x01\x02\x03\x04\x87\x10\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x03EVx\x81\x0b[email protected]\xa4$0\"1\x110\x0f\x06\x03U\x04\x03\x0c\x08John Doe1\x0d0\x0b\x06\x03U\x04\x0a\x0c\x04Acme", | ||
}, | ||
{ | ||
:input => "RID:1.3.6.1.3.100.200", | ||
:der => "0\x12\x06\x03U\x1d\x11\x04\x0b0\x09\x88\x07+\x06\x01\x03d\x81H", | ||
}, | ||
] | ||
|
||
extensions = OpenSSL::X509::ExtensionFactory.new | ||
ext = extensions.create_extension("subjectAltName", "email:[email protected],DNS:a.b.com,email:[email protected]") | ||
assert_equal 'subjectAltName', ext.oid | ||
assert_equal 'email:[email protected], DNS:a.b.com, email:[email protected]', ext.value | ||
mri_der = "0,\x06\x03U\x1D\x11\x04%0#\x81\v[email protected]\x82\aa.b.com\x81\v[email protected]" | ||
assert_equal mri_der, ext.to_der | ||
tests.each { |test| | ||
ext = extensions.create_extension("subjectAltName", test[:input]) | ||
assert_equal 'subjectAltName', ext.oid | ||
assert_equal (test[:output] || test[:input]), ext.value | ||
assert_equal test[:der], ext.to_der | ||
} | ||
end | ||
|
||
def subject_alt_name(domains) | ||
|
@@ -165,4 +191,4 @@ def subject_alt_name(domains) | |
end | ||
private :subject_alt_name | ||
|
||
end | ||
end |