This repository was archived by the owner on Oct 18, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ var Shaaa = {
105105 var tlsOptions = {
106106 host : domain ,
107107 servername : domain ,
108+ ca : 'x' , // prevents adding known roots to response
108109 port : port ,
109110 rejectUnauthorized : false
110111 } ;
@@ -118,19 +119,24 @@ var Shaaa = {
118119 socket . on ( 'close' , function ( ) {
119120 if ( options . verbose || options . debug ) console . log ( '[tlsSocket] disconnected' ) ;
120121
121- // Walk through peerCert object. Grab DER-encoded certs. Convert to PEM and push to certsArray.
122+ // Walk the depth of the peerCert object. Grab DER-encoded certs. Convert to PEM and push to certsArray.
122123 var certsArray = [ ] ;
123- function eachDer ( cert ) {
124- if ( cert ) {
125- var pem = Shaaa . derToPem ( cert . raw ) ;
124+ var maxdepth = 7 ;
125+ if ( peerCert ) {
126+ var depth = 0 ;
127+ while ( depth < maxdepth ) {
128+ var pem = Shaaa . derToPem ( peerCert . raw ) ;
126129 if ( pem ) {
127130 certsArray . push ( x509 . parseCert ( pem ) ) ;
128- if ( cert . issuerCertificate !== cert ) // peerCert contains circular obj ref. This stops us.
129- eachDer ( cert . issuerCertificate ) ;
130- }
131+ if ( peerCert . issuerCertificate && ( peerCert . issuerCertificate !== peerCert ) )
132+ peerCert = peerCert . issuerCertificate ;
133+ else
134+ break ; // no more depth levels
135+ } else
136+ break ; // no more certs
137+ ++ depth ;
131138 }
132139 }
133- eachDer ( peerCert ) ;
134140
135141 if ( certsArray . length == 0 )
136142 callback ( { message : "No certs returned" } ) ;
You can’t perform that action at this time.
0 commit comments