summaryrefslogtreecommitdiff
path: root/lib/_tls_wrap.js
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-11-08 13:40:46 -0800
committerSam Roberts <vieuxtech@gmail.com>2018-11-13 20:42:57 -0800
commitdb35fee1e1ca909f0f33940c0d9501a72baf2375 (patch)
tree789d1749dffbbd7fa28da4751edd21a314cce9f5 /lib/_tls_wrap.js
parent98278584ee2c322655849e6d673ac1739e720b53 (diff)
downloadandroid-node-v8-db35fee1e1ca909f0f33940c0d9501a72baf2375.tar.gz
android-node-v8-db35fee1e1ca909f0f33940c0d9501a72baf2375.tar.bz2
android-node-v8-db35fee1e1ca909f0f33940c0d9501a72baf2375.zip
tls: get the local certificate after tls handshake
Add an API to get the local certificate chosen during TLS handshake from the SSL context. Fix: https://github.com/nodejs/node/issues/24095 PR-URL: https://github.com/nodejs/node/pull/24261 Fixes: https://github.com/nodejs/node/issues/24095 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'lib/_tls_wrap.js')
-rw-r--r--lib/_tls_wrap.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index f0d86f3d87..2e32366028 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -660,7 +660,17 @@ TLSSocket.prototype.setSession = function(session) {
TLSSocket.prototype.getPeerCertificate = function(detailed) {
if (this._handle) {
return common.translatePeerCertificate(
- this._handle.getPeerCertificate(detailed));
+ this._handle.getPeerCertificate(detailed)) || {};
+ }
+
+ return null;
+};
+
+TLSSocket.prototype.getCertificate = function() {
+ if (this._handle) {
+ // It's not a peer cert, but the formatting is identical.
+ return common.translatePeerCertificate(
+ this._handle.getCertificate()) || {};
}
return null;