diff --git a/doc/api/tls.markdown b/doc/api/tls.markdown index 657f690343ff03..b001712b64e42f 100644 --- a/doc/api/tls.markdown +++ b/doc/api/tls.markdown @@ -725,7 +725,8 @@ Example: valid_from: 'Nov 11 09:52:22 2009 GMT', valid_to: 'Nov 6 09:52:22 2029 GMT', fingerprint: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF', - serialNumber: 'B9B0D332A1AA5635' } + serialNumber: 'B9B0D332A1AA5635', + subjectPublicKeyInfo: < SPKI DER buffer > } If the peer does not provide a certificate, it returns `null` or an empty object. diff --git a/src/env.h b/src/env.h index ab586b39b09dea..68bfeaa945759c 100644 --- a/src/env.h +++ b/src/env.h @@ -165,7 +165,6 @@ namespace node { V(priority_string, "priority") \ V(processed_string, "processed") \ V(prototype_string, "prototype") \ - V(public_key_string, "publicKey") \ V(raw_string, "raw") \ V(rdev_string, "rdev") \ V(readable_string, "readable") \ @@ -194,6 +193,7 @@ namespace node { V(status_string, "status") \ V(stdio_string, "stdio") \ V(subject_string, "subject") \ + V(subject_public_key_info_string, "subjectPublicKeyInfo") \ V(subjectaltname_string, "subjectaltname") \ V(sys_string, "sys") \ V(syscall_string, "syscall") \ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3eba4aa08efb0d..f4a584c1d742bb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1225,7 +1225,7 @@ static Local X509ToObject(Environment* env, X509* cert) { unsigned char* pkey_serialized = reinterpret_cast( Buffer::Data(pkey_buff)); i2d_PUBKEY(pkey, &pkey_serialized); - info->Set(env->public_key_string(), pkey_buff); + info->Set(env->subject_public_key_info_string(), pkey_buff); } if (rsa != nullptr) { diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index 8f408b2938369e..3c7598478fda13 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -19,10 +19,10 @@ var options = { }; var verified = false; -var expectedBase64PublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC46ze' + - 'FbysX7vHHmIH3COYiB34dOpEVR4rEb6ZZXfkeXoDe7NgZfBbOeqw6iavhr9SRmvFs8ank' + - 'DCpr2DvY0X3uDdLKyrYNbhrfJxdYB5hhwdKVHGokZdOPH68b/ScMJcsGGgMo7TTMRxx2M' + - 'ZLzESOOJ5BCv4p4BKYibSRCa43lhwIDAQAB'; +var expectedBase64SubjectPublicKeyInfo = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB' + + 'iQKBgQC46zeFbysX7vHHmIH3COYiB34dOpEVR4rEb6ZZXfkeXoDe7NgZfBbOeqw6iavhr' + + '9SRmvFs8ankDCpr2DvY0X3uDdLKyrYNbhrfJxdYB5hhwdKVHGokZdOPH68b/ScMJcsGGg' + + 'Mo7TTMRxx2MZLzESOOJ5BCv4p4BKYibSRCa43lhwIDAQAB'; var server = tls.createServer(options, function(cleartext) { cleartext.end('World'); @@ -42,8 +42,8 @@ server.listen(common.PORT, function() { common.debug(util.inspect(peerCert)); assert.equal(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); assert.equal(peerCert.serialNumber, '9A84ABCFB8A72AC0'); - assert.equal(peerCert.publicKey.toString('base64'), - expectedBase64PublicKey); + assert.equal(peerCert.subjectPublicKeyInfo.toString('base64'), + expectedBase64SubjectPublicKeyInfo); assert.deepEqual(peerCert.infoAccess['OCSP - URI'], [ 'http://ocsp.nodejs.org/' ]);