Skip to content

Commit

Permalink
test: move foafssl certs to fixtures/keys/
Browse files Browse the repository at this point in the history
PR-URL: nodejs#27962
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
reasonablytall authored and ofrobots committed Jun 5, 2019
1 parent c49e378 commit 7aa79be
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 72 deletions.
25 changes: 0 additions & 25 deletions test/fixtures/foafssl.crt

This file was deleted.

32 changes: 0 additions & 32 deletions test/fixtures/foafssl.key

This file was deleted.

14 changes: 14 additions & 0 deletions test/fixtures/keys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ all: \
rsa_private_b.pem \
I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 \
rsa_public_b.pem \
rsa_cert_foafssl_b.crt \
rsa_cert_foafssl_b.modulus \
rsa_cert_foafssl_b.exponent \
rsa_spkac.spkac \
rsa_spkac_invalid.spkac \
rsa_private_1024.pem \
Expand Down Expand Up @@ -648,6 +651,17 @@ I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256: rsa_private_b.pe
rsa_public_b.pem: rsa_private_b.pem
openssl rsa -in rsa_private_b.pem -pubout -out rsa_public_b.pem

rsa_cert_foafssl_b.crt: rsa_private_b.pem
openssl req -new -x509 -config rsa_cert_foafssl_b.cnf -key rsa_private_b.pem -out rsa_cert_foafssl_b.crt

# The 'modulus=' in the output must be stripped out
rsa_cert_foafssl_b.modulus: rsa_cert_foafssl_b.crt
openssl x509 -modulus -in rsa_cert_foafssl_b.crt -noout | cut -c 9- > rsa_cert_foafssl_b.modulus

# Have to parse out the hex exponent
rsa_cert_foafssl_b.exponent: rsa_cert_foafssl_b.crt
openssl x509 -in rsa_cert_foafssl_b.crt -text | grep -o 'Exponent:.*' | sed 's/\(.*(\|).*\)//g' > rsa_cert_foafssl_b.exponent

# openssl outputs `SPKAC=[SPKAC]`. That prefix needs to be removed to work with node
rsa_spkac.spkac: rsa_private.pem
openssl spkac -key rsa_private.pem -challenge this-is-a-challenge | cut -c 7- > rsa_spkac.spkac
Expand Down
24 changes: 24 additions & 0 deletions test/fixtures/keys/rsa_cert_foafssl_b.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[ req ]
days = 99999
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
x509_extensions = v3_ca

[ req_distinguished_name ]
C = UK
ST = "FOAF+SSL Auth Certificate"
L = Rhys Jones
O = node.js
OU = Test TLS Certificate
CN = localhost
emailAddress = alex@aub.dev

[ req_attributes ]

[ v3_ca ]
basicConstraints = CA:FALSE
subjectAltName = @alt_names

[ alt_names ]
URI = http://example.com/\#me
24 changes: 24 additions & 0 deletions test/fixtures/keys/rsa_cert_foafssl_b.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEEDCCAvigAwIBAgIUAhzZrkGH3j4aXirSjA6n87moF9kwDQYJKoZIhvcNAQEL
BQAwgagxCzAJBgNVBAYTAlVLMSIwIAYDVQQIDBlGT0FGK1NTTCBBdXRoIENlcnRp
ZmljYXRlMRMwEQYDVQQHDApSaHlzIEpvbmVzMRAwDgYDVQQKDAdub2RlLmpzMR0w
GwYDVQQLDBRUZXN0IFRMUyBDZXJ0aWZpY2F0ZTESMBAGA1UEAwwJbG9jYWxob3N0
MRswGQYJKoZIhvcNAQkBFgxhbGV4QGF1Yi5kZXYwHhcNMTkwNTI5MjIzMjM1WhcN
MTkwNjI4MjIzMjM1WjCBqDELMAkGA1UEBhMCVUsxIjAgBgNVBAgMGUZPQUYrU1NM
IEF1dGggQ2VydGlmaWNhdGUxEzARBgNVBAcMClJoeXMgSm9uZXMxEDAOBgNVBAoM
B25vZGUuanMxHTAbBgNVBAsMFFRlc3QgVExTIENlcnRpZmljYXRlMRIwEAYDVQQD
DAlsb2NhbGhvc3QxGzAZBgkqhkiG9w0BCQEWDGFsZXhAYXViLmRldjCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMm9YK6zftvX8XnhG02khI2ukyg06U/1
l56qxQkvoeyGHJw6AFcHLD1ORWXlD7yyjM4vTR0id+C0Arq6h4B/F/nMNGE94HWE
v+6qEIl7Psyr+teTXLbQ98ZUC3HmPjcM56D18smcDnmaslOR4qm66ruoXa+oEGKI
DDS59jcQVtqRnoHevmRjAl9/vwbTD/+rV5rbWI2PsoTdkqxs+XCoVqXB4gul/ge7
giqCmcvrdo1MWFSlMFq9WbjPJKUp7lQnL9TqDBhIphBwO7/3mhf8vs/1XUOGPPBo
U51TeCm7YGfqPT6IY8SxVOtlXkwC4sVOZj0CkoEiAin43r9BVFLqxesCAwEAAaMw
MC4wCQYDVR0TBAIwADAhBgNVHREEGjAYhhZodHRwOi8vZXhhbXBsZS5jb20vI21l
MA0GCSqGSIb3DQEBCwUAA4IBAQBMRbs4ERIJmZz6GAaI85vbwR166S+g5rkNK8iZ
jMAeSD9O2/ZT3JhGfh+f/m7cy1+RiARVSZOgd0nN/L6U6JlPbjtK92CpIx+gDw67
lYV3QQCGU0tNQ1EFNzj6A7Mi/zSZ5wBbTi886xYztLPSjWEHt+8pShHga/Qi3alN
3haN/UvyamKgmWna8s3zWrCEZwW7D+XQqWoA2EISlnIdX46agHgmU30+TalGDAzf
OFwGvEfkyHTrrl6TxwdLU8fWsEcBOF6Ukg7kEc1aCBgd3cD9LI8g2N8DQdkWGGEQ
innpMWv59H2v3gVMj/0/BPGthQMTHMrhKWZZ1QGjkId7tHro
-----END CERTIFICATE-----
1 change: 1 addition & 0 deletions test/fixtures/keys/rsa_cert_foafssl_b.exponent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x10001
1 change: 1 addition & 0 deletions test/fixtures/keys/rsa_cert_foafssl_b.modulus
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C9BD60AEB37EDBD7F179E11B4DA4848DAE932834E94FF5979EAAC5092FA1EC861C9C3A0057072C3D4E4565E50FBCB28CCE2F4D1D2277E0B402BABA87807F17F9CC34613DE07584BFEEAA10897B3ECCABFAD7935CB6D0F7C6540B71E63E370CE7A0F5F2C99C0E799AB25391E2A9BAEABBA85DAFA81062880C34B9F6371056DA919E81DEBE6463025F7FBF06D30FFFAB579ADB588D8FB284DD92AC6CF970A856A5C1E20BA5FE07BB822A8299CBEB768D4C5854A5305ABD59B8CF24A529EE54272FD4EA0C1848A610703BBFF79A17FCBECFF55D43863CF068539D537829BB6067EA3D3E8863C4B154EB655E4C02E2C54E663D029281220229F8DEBF415452EAC5EB
24 changes: 9 additions & 15 deletions test/parallel/test-https-foafssl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,15 @@ const https = require('https');
const spawn = require('child_process').spawn;

const options = {
key: fixtures.readSync('agent.key'),
cert: fixtures.readSync('agent.crt'),
key: fixtures.readKey('rsa_private.pem'),
cert: fixtures.readKey('rsa_cert.crt'),
requestCert: true,
rejectUnauthorized: false
};

const modulus = 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC3A5519F' +
'349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C289646' +
'94B2047D217B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560C' +
'DE9C13455552B2F49CF0FB00D8D77532324913F6F80FF29D0A131D29DB06' +
'AFF8BE191B7920DC2DAE1C26EA82A47847A10391EF3BF6AABB3CC40FF821' +
'00B03A4F0FF1809278E4DDFDA7DE954ED56DC7AD9A47EEBC37D771A366FC' +
'60A5BCB72373BEC180649B3EFA0E9092707210B41B90032BB18BC91F2046' +
'EBDAF1191F4A4E26D71879C4C7867B62FCD508E8CE66E82D128A71E91580' +
'9FCF44E8DE774067F1DE5D70B9C03687';
const webIdUrl = 'URI:http://example.com/#me';
const modulus = fixtures.readKey('rsa_cert_foafssl_b.modulus', 'ascii').replace(/\n/g, '');
const exponent = fixtures.readKey('rsa_cert_foafssl_b.exponent', 'ascii').replace(/\n/g, '');

const CRLF = '\r\n';
const body = 'hello world\n';
Expand All @@ -58,8 +52,8 @@ const server = https.createServer(options, common.mustCall(function(req, res) {

cert = req.connection.getPeerCertificate();

assert.strictEqual(cert.subjectaltname, 'URI:http://example.com/#me');
assert.strictEqual(cert.exponent, '0x10001');
assert.strictEqual(cert.subjectaltname, webIdUrl);
assert.strictEqual(cert.exponent, exponent);
assert.strictEqual(cert.modulus, modulus);
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(body);
Expand All @@ -69,8 +63,8 @@ server.listen(0, function() {
const args = ['s_client',
'-quiet',
'-connect', `127.0.0.1:${this.address().port}`,
'-cert', fixtures.path('foafssl.crt'),
'-key', fixtures.path('foafssl.key')];
'-cert', fixtures.path('keys/rsa_cert_foafssl_b.crt'),
'-key', fixtures.path('keys/rsa_private_b.pem')];

const client = spawn(common.opensslCli, args);

Expand Down

0 comments on commit 7aa79be

Please sign in to comment.