From d5019c05da10857ff34b26d27177302cd8b23504 Mon Sep 17 00:00:00 2001 From: Nils Neumann Date: Wed, 26 Jul 2023 16:29:43 +0200 Subject: [PATCH 1/2] Add pseudonym OID --- lib/oids.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oids.js b/lib/oids.js index d1504eb16..817ed1be2 100644 --- a/lib/oids.js +++ b/lib/oids.js @@ -123,6 +123,7 @@ _IN('2.5.4.13', 'description'); _IN('2.5.4.15', 'businessCategory'); _IN('2.5.4.17', 'postalCode'); _IN('2.5.4.42', 'givenName'); +_IN('2.5.4.65', 'pseudonym'); _IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName'); _IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName'); From 5ed0090d8b69d74e0bc38b20c9d8f4ac19b86a59 Mon Sep 17 00:00:00 2001 From: Nils Neumann Date: Wed, 26 Jul 2023 17:30:05 +0200 Subject: [PATCH 2/2] Add unit test for "pseudonym" --- tests/unit/x509.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/unit/x509.js b/tests/unit/x509.js index 474e97a89..34d6bab0d 100644 --- a/tests/unit/x509.js +++ b/tests/unit/x509.js @@ -616,6 +616,52 @@ var UTIL = require('../../lib/util'); ASSERT.equal(attribute.value, 'Test Avenue'); }); + it('should generate a certificate with pseudonym attribute', function() { + var keys = { + privateKey: PKI.privateKeyFromPem(_pem.privateKey), + publicKey: PKI.publicKeyFromPem(_pem.publicKey) + }; + var attrs = [{ + name: 'commonName', + value: 'example.org' + }, { + name: 'countryName', + value: 'US' + }, { + shortName: 'ST', + value: 'Virginia' + }, { + name: 'localityName', + value: 'Blacksburg' + }, { + name: 'organizationName', + value: 'Test' + }, { + shortName: 'OU', + value: 'Test' + }, { + name: 'pseudonym', + value: 'Satoshi Nakamato' + }]; + var cert = createCertificate({ + publicKey: keys.publicKey, + signingKey: keys.privateKey, + serialNumber: '01', + subject: attrs, + issuer: attrs, + isCA: true + }); + + var pem = PKI.certificateToPem(cert); + cert = PKI.certificateFromPem(pem); + var index = findIndex(cert.subject.attributes, {type: '2.5.4.65'}); + ASSERT.ok(index !== -1); + var attribute = cert.subject.attributes[index]; + ASSERT.equal(attribute.name, 'pseudonym'); + ASSERT.equal(attribute.value, 'Satoshi Nakamato'); + }); + + it('should generate a certificate with jurisdictionOfIncorporationStateOrProvinceName attribute', function() { var keys = { privateKey: PKI.privateKeyFromPem(_pem.privateKey),