Skip to content

Commit

Permalink
crypto: separate altname extensions with ", "
Browse files Browse the repository at this point in the history
In newly introduced `SafeX509ExtPrint` I forgot to insert separators
between extensions, which lead to the "DNS:...DNS:..." thing for npm.

Fix: #105
Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: https://github.com/iojs/io.js/pull/113.patch
  • Loading branch information
indutny committed Dec 10, 2014
1 parent ac18ebd commit 687dfc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,9 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) {
for (int i = 0; i < sk_GENERAL_NAME_num(names); i++) {
GENERAL_NAME* gen = sk_GENERAL_NAME_value(names, i);

if (i != 0)
BIO_write(out, ", ", 2);

if (gen->type == GEN_DNS) {
ASN1_IA5STRING* name = gen->d.dNSName;

Expand Down
23 changes: 12 additions & 11 deletions test/fixtures/keys/0-dns-cert.pem
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIC2jCCAcSgAwIBAgICJxEwCwYJKoZIhvcNAQEFMBUxEzARBgNVBAMWCm9oLm15
Lmdvc2gwHxcNMTQxMTA1MDMyMDUyWhcOMzQwMTAzMTAzMjA1MlowEzERMA8GA1UE
AxYIZXZpbC5jb20wggEfMAsGCSqGSIb3DQEBAQOCAQ4AMIIBCQKCAQCsFwwf1dsr
MIIC/zCCAemgAwIBAgICJxEwCwYJKoZIhvcNAQEFMBUxEzARBgNVBAMWCm9oLm15
Lmdvc2gwHhcNMTQxMjA4MTM0MTUzWhcNMzQxMjAzMTM0MTUzWjATMREwDwYDVQQD
FghldmlsLmNvbTCCASAwCwYJKoZIhvcNAQEBA4IBDwAwggEKAoIBAQCsFwwf1dsr
PdxyTHBreymbFGACLQtaOihGsSkYtIzUEF1aT90YDMzNdoLr4wkwWig5FPRMnjmX
7pXY9RVbW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pk/B32e3yWowbvG7OxuUL0F
1w4DD2m+GfbTyZSCfYKP/zMp3xhTxihVfZ2g07ufc51bNCftWKBLHM/QHJmn4pVo
rrz1vS9nMf/i16zrJ8Xmj61Eo4Aes37lAH5kUiT1VsNxSDcQCiqr1mcj6ByXKNCQ
wDzO
-----END CERTIFICATE-----
7 changes: 6 additions & 1 deletion test/simple/test-tls-0-dns-altname.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ var server = tls.createServer({
}, function() {
requests++;
var cert = c.getPeerCertificate();
assert.equal(cert.subjectaltname, 'DNS:google.com\0.evil.com');
assert.equal(cert.subjectaltname,
'DNS:google.com\0.evil.com, ' +
'DNS:just-another.com, ' +
'IP Address:8.8.8.8, '+
'IP Address:8.8.4.4, '+
'DNS:last.com');
c.write('ok');
});
});
Expand Down

0 comments on commit 687dfc9

Please sign in to comment.