From 8670f6dd221010c8e8effb9e4ca07794ce126de5 Mon Sep 17 00:00:00 2001 From: Alex Aubuchon Date: Wed, 29 May 2019 10:16:07 -0700 Subject: [PATCH] test: move spkac certs to fixtures/keys/ PR-URL: https://github.com/nodejs/node/pull/27962 Reviewed-By: Sam Roberts Reviewed-By: Ujjwal Sharma Reviewed-By: Rich Trott --- test/fixtures/keys/Makefile | 10 ++++++++++ test/fixtures/keys/rsa_spkac.spkac | 1 + test/fixtures/keys/rsa_spkac_invalid.spkac | 1 + test/fixtures/spkac.fail | 1 - test/fixtures/spkac.pem | 6 ------ test/fixtures/spkac.valid | 1 - test/parallel/test-crypto-certificate.js | 11 ++++++----- 7 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 test/fixtures/keys/rsa_spkac.spkac create mode 100644 test/fixtures/keys/rsa_spkac_invalid.spkac delete mode 100644 test/fixtures/spkac.fail delete mode 100644 test/fixtures/spkac.pem delete mode 100644 test/fixtures/spkac.valid diff --git a/test/fixtures/keys/Makefile b/test/fixtures/keys/Makefile index 8ca9e4d26c17f6..fd7ca677f63266 100644 --- a/test/fixtures/keys/Makefile +++ b/test/fixtures/keys/Makefile @@ -46,6 +46,8 @@ all: \ rsa_private_b.pem \ I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256 \ rsa_public_b.pem \ + rsa_spkac.spkac \ + rsa_spkac_invalid.spkac \ rsa_private_1024.pem \ rsa_private_2048.pem \ rsa_private_4096.pem \ @@ -630,6 +632,14 @@ 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 +# 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 + +# cutting characters from the start to invalidate the spkac +rsa_spkac_invalid.spkac: rsa_spkac.spkac + cat rsa_spkac.spkac | cut -c 5- > rsa_spkac_invalid.spkac + rsa_private_1024.pem: openssl genrsa -out rsa_private_1024.pem 1024 diff --git a/test/fixtures/keys/rsa_spkac.spkac b/test/fixtures/keys/rsa_spkac.spkac new file mode 100644 index 00000000000000..35627672968172 --- /dev/null +++ b/test/fixtures/keys/rsa_spkac.spkac @@ -0,0 +1 @@ +MIICUzCCATswggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC33FiIiiexwLe/P8DZx5HsqFlmUO7/lvJ7necJVNwqdZ3ax5jpQB0p6uxfqeOvzcN3k5V7UFb/Am+nkSNZMAZhsWzCU2Z4Pjh50QYz3f0Hour7/yIGStOLyYY3hgLK2K8TbhgjQPhdkw9+QtKlpvbL8fLgONAoGrVOFnRQGcr70iFffsm79mgZhKVMgYiHPJqJgGHvCtkGg9zMgS7p63+Q3ZWedtFS2RhMX3uCBy/mH6EOlRCNBbRmA4xxNzyf5GQaki3T+Iz9tOMjdPP+CwV2LqEdylmBuik8vrfTb3qIHLKKBAI8lXN26wWtA3kN4L7NP+cbKlCRlqctvhmylLH1AgMBAAEWE3RoaXMtaXMtYS1jaGFsbGVuZ2UwDQYJKoZIhvcNAQEEBQADggEBAIozmeW1kfDfAVwRQKileZGLRGCD7AjdHLYEe16xTBPve8Af1bDOyuWsAm4qQLYA4FAFROiKeGqxCtIErEvm87/09tCfF1My/1Uj+INjAk39DK9J9alLlTsrwSgd1lb3YlXY7TyitCmh7iXLo4pVhA2chNA3njiMq3CUpSvGbpzrESL2dv97lv590gUD988wkTDVyYsf0T8+X0Kww3AgPWGji+2f2i5/jTfD/s1lK1nqi7ZxFm0pGZoy1MJ51SCEy7Y82ajroI+5786nC02mo9ak7samca4YDZOoxN4d3tax4B/HDF5dqJSm1/31xYLDTfujCM5FkSjRc4m6hnriEkc= diff --git a/test/fixtures/keys/rsa_spkac_invalid.spkac b/test/fixtures/keys/rsa_spkac_invalid.spkac new file mode 100644 index 00000000000000..0460a32b810216 --- /dev/null +++ b/test/fixtures/keys/rsa_spkac_invalid.spkac @@ -0,0 +1 @@ +UzCCATswggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC33FiIiiexwLe/P8DZx5HsqFlmUO7/lvJ7necJVNwqdZ3ax5jpQB0p6uxfqeOvzcN3k5V7UFb/Am+nkSNZMAZhsWzCU2Z4Pjh50QYz3f0Hour7/yIGStOLyYY3hgLK2K8TbhgjQPhdkw9+QtKlpvbL8fLgONAoGrVOFnRQGcr70iFffsm79mgZhKVMgYiHPJqJgGHvCtkGg9zMgS7p63+Q3ZWedtFS2RhMX3uCBy/mH6EOlRCNBbRmA4xxNzyf5GQaki3T+Iz9tOMjdPP+CwV2LqEdylmBuik8vrfTb3qIHLKKBAI8lXN26wWtA3kN4L7NP+cbKlCRlqctvhmylLH1AgMBAAEWE3RoaXMtaXMtYS1jaGFsbGVuZ2UwDQYJKoZIhvcNAQEEBQADggEBAIozmeW1kfDfAVwRQKileZGLRGCD7AjdHLYEe16xTBPve8Af1bDOyuWsAm4qQLYA4FAFROiKeGqxCtIErEvm87/09tCfF1My/1Uj+INjAk39DK9J9alLlTsrwSgd1lb3YlXY7TyitCmh7iXLo4pVhA2chNA3njiMq3CUpSvGbpzrESL2dv97lv590gUD988wkTDVyYsf0T8+X0Kww3AgPWGji+2f2i5/jTfD/s1lK1nqi7ZxFm0pGZoy1MJ51SCEy7Y82ajroI+5786nC02mo9ak7samca4YDZOoxN4d3tax4B/HDF5dqJSm1/31xYLDTfujCM5FkSjRc4m6hnriEkc= diff --git a/test/fixtures/spkac.fail b/test/fixtures/spkac.fail deleted file mode 100644 index 4dc12f88bfed12..00000000000000 --- a/test/fixtures/spkac.fail +++ /dev/null @@ -1 +0,0 @@ -MIIB/FAILDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkZmI5YWI4MTQtNjY3Ny00MmE0LWE2MGMtZjkwNWQxYTY5MjRkMA0GCSqGSIb3DQEBBQUAA4GBADu1U9t3eY9O3WOofp1RHX2rkh0TPs1CeS+sNdWUSDmdV5ifaGdeXpDikEnh4QIUIeZehxwgy2EjiZqMjMJHF++KPTzfAnHuuEtpDmIGzBnodZa1qt322iGZwgREvacv78GxJBJvPP3KLe+EDDsERG1aWLJoSZRusadacdzNmdV4 diff --git a/test/fixtures/spkac.pem b/test/fixtures/spkac.pem deleted file mode 100644 index 4ad1cdd0bf0d3c..00000000000000 --- a/test/fixtures/spkac.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcvQh9SKOPv4DwI8LwSaFx02h7 -l9QCiDs6sF2GfsSTEUG61SnjQ/v4uJiLKBgbVOagj9rkSCwtTez23ATPeGaBj2Zg -ipv+tv5IXyqUP8ropXJQ5ELtaXPUN/gvw7cO5EbPHr/7eMhbpw8Gl+AfWxW5hLW8 -MGw/+AwwjHBOwong/QIDAQAB ------END PUBLIC KEY----- diff --git a/test/fixtures/spkac.valid b/test/fixtures/spkac.valid deleted file mode 100644 index 6bfe5bb90d5e58..00000000000000 --- a/test/fixtures/spkac.valid +++ /dev/null @@ -1 +0,0 @@ -MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkZmI5YWI4MTQtNjY3Ny00MmE0LWE2MGMtZjkwNWQxYTY5MjRkMA0GCSqGSIb3DQEBBQUAA4GBADu1U9t3eY9O3WOofp1RHX2rkh0TPs1CeS+sNdWUSDmdV5ifaGdeXpDikEnh4QIUIeZehxwgy2EjiZqMjMJHF++KPTzfAnHuuEtpDmIGzBnodZa1qt322iGZwgREvacv78GxJBJvPP3KLe+EDDsERG1aWLJoSZRusadacdzNmdV4 diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index a426e0be003da0..e987be212958a7 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/test/parallel/test-crypto-certificate.js @@ -30,9 +30,10 @@ const { Certificate } = crypto; const fixtures = require('../common/fixtures'); // Test Certificates -const spkacValid = fixtures.readSync('spkac.valid'); -const spkacFail = fixtures.readSync('spkac.fail'); -const spkacPem = fixtures.readSync('spkac.pem'); +const spkacValid = fixtures.readKey('rsa_spkac.spkac'); +const spkacChallenge = 'this-is-a-challenge'; +const spkacFail = fixtures.readKey('rsa_spkac_invalid.spkac'); +const spkacPublicPem = fixtures.readKey('rsa_public.pem'); function checkMethods(certificate) { @@ -41,13 +42,13 @@ function checkMethods(certificate) { assert.strictEqual( stripLineEndings(certificate.exportPublicKey(spkacValid).toString('utf8')), - stripLineEndings(spkacPem.toString('utf8')) + stripLineEndings(spkacPublicPem.toString('utf8')) ); assert.strictEqual(certificate.exportPublicKey(spkacFail), ''); assert.strictEqual( certificate.exportChallenge(spkacValid).toString('utf8'), - 'fb9ab814-6677-42a4-a60c-f905d1a6924d' + spkacChallenge ); assert.strictEqual(certificate.exportChallenge(spkacFail), ''); }