Skip to content

Commit fd05b71

Browse files
committed
fixup
1 parent 6212086 commit fd05b71

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

test/fixtures/0-dns/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ $ npm install
2222

2323
$ node ./createCert.js
2424
$ openssl x509 -text -in 0-dns-cert.pem
25-
(You can not see evel.example.com in subjectAltName field)
25+
(You can not see evil.example.com in subjectAltName field)
2626
```

test/fixtures/0-dns/createCert.js renamed to test/fixtures/0-dns/create-cert.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2-
const fs = require('fs');
2+
const asn1 = require('asn1.js');
33
const crypto = require('crypto');
4+
const fs = require('fs');
45
const rfc5280 = require('asn1.js-rfc5280');
5-
const asn1 = require('asn1.js');
66
const BN = asn1.bignum;
77

88
const id_at_commonName = [ 2, 5, 4, 3 ];
@@ -12,7 +12,7 @@ const sigalg = 'RSA-SHA256';
1212

1313
const private_key = fs.readFileSync('./0-dns-key.pem');
1414
// public key file can be generated from the private key with
15-
// openssl rsa -in 0-dns-key.pem -RSAPublicKey_out -outform der \
15+
// openssl rsa -in 0-dns-key.pem -RSAPublicKey_out -outform der
1616
// -out 0-dns-rsapub.der
1717
const public_key = fs.readFileSync('./0-dns-rsapub.der');
1818

@@ -30,32 +30,32 @@ const PrintStr = asn1.define('PrintStr', function() {
3030
const issuer = PrintStr.encode('ca.example.com', 'der');
3131
const subject = PrintStr.encode('evil.example.com', 'der');
3232

33-
const tbs =
34-
{ version: 'v3',
35-
serialNumber: new BN('01', 16),
36-
signature: { algorithm: sha256WithRSAEncryption, parameters: null_},
37-
issuer: { type: 'rdnSequence',
38-
value: [ [{type: id_at_commonName, value: issuer}] ] },
39-
validity:
40-
{ notBefore: { type: 'utcTime', value: now },
41-
notAfter: { type: 'utcTime', value: now + days * 86400000} },
42-
subject: { type: 'rdnSequence',
43-
value: [ [{type: id_at_commonName, value: subject}] ] },
44-
subjectPublicKeyInfo:
45-
{ algorithm: { algorithm: rsaEncryption, parameters: null_},
46-
subjectPublicKey: { unused: 0, data: public_key} },
47-
extensions:
48-
[ { extnID: 'subjectAlternativeName',
49-
critical: false,
50-
// subjectAltName which contains '\0' character to check CVE-2009-2408
51-
extnValue: [
52-
{ type: 'dNSName', value: 'good.example.org\u0000.evil.example.com' },
53-
{ type: 'dNSName', value: 'just-another.example.com' },
54-
{ type: 'iPAddress', value: Buffer.from('08080808', 'hex') },
55-
{ type: 'iPAddress', value: Buffer.from('08080404', 'hex') },
56-
{ type: 'dNSName', value: 'last.example.com' } ] }
57-
]
58-
};
33+
const tbs = {
34+
version: 'v3',
35+
serialNumber: new BN('01', 16),
36+
signature: { algorithm: sha256WithRSAEncryption, parameters: null_},
37+
issuer: { type: 'rdnSequence',
38+
value: [ [{type: id_at_commonName, value: issuer}] ] },
39+
validity:
40+
{ notBefore: { type: 'utcTime', value: now },
41+
notAfter: { type: 'utcTime', value: now + days * 86400000} },
42+
subject: { type: 'rdnSequence',
43+
value: [ [{type: id_at_commonName, value: subject}] ] },
44+
subjectPublicKeyInfo:
45+
{ algorithm: { algorithm: rsaEncryption, parameters: null_},
46+
subjectPublicKey: { unused: 0, data: public_key} },
47+
extensions:
48+
[ { extnID: 'subjectAlternativeName',
49+
critical: false,
50+
// subjectAltName which contains '\0' character to check CVE-2009-2408
51+
extnValue: [
52+
{ type: 'dNSName', value: 'good.example.org\u0000.evil.example.com' },
53+
{ type: 'dNSName', value: 'just-another.example.com' },
54+
{ type: 'iPAddress', value: Buffer.from('08080808', 'hex') },
55+
{ type: 'iPAddress', value: Buffer.from('08080404', 'hex') },
56+
{ type: 'dNSName', value: 'last.example.com' } ] }
57+
]
58+
};
5959

6060
const tbs_der = rfc5280.TBSCertificate.encode(tbs, 'der');
6161

@@ -65,10 +65,10 @@ const signature = sign.sign(private_key);
6565

6666
const cert = {
6767
tbsCertificate: tbs,
68-
signatureAlgorithm: { algorithm: sha256WithRSAEncryption, parameters: null_},
68+
signatureAlgorithm: { algorithm: sha256WithRSAEncryption, parameters: null_ },
6969
signature:
7070
{ unused: 0,
71-
data: signature}
71+
data: signature }
7272
};
7373
const pem = rfc5280.Certificate.encode(cert, 'pem', {label: 'CERTIFICATE'});
7474

test/parallel/test-tls-0-dns-altname.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../common');
33
const assert = require('assert');
44

5-
// check getPeerCertificate can properly handle '\0' for fix CVE-2009-2408
5+
// Check getPeerCertificate can properly handle '\0' for fix CVE-2009-2408.
66

77
if (!common.hasCrypto) {
88
common.skip('missing crypto');

0 commit comments

Comments
 (0)