File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1875,10 +1875,10 @@ void SSLWrap<Base>::GetCertificate(
1875
1875
1876
1876
Local<Object> result;
1877
1877
1878
- X509Pointer cert ( SSL_get_certificate (w->ssl_ .get () ));
1878
+ X509* cert = SSL_get_certificate (w->ssl_ .get ());
1879
1879
1880
- if (cert)
1881
- result = X509ToObject (env, cert. get () );
1880
+ if (cert != nullptr )
1881
+ result = X509ToObject (env, cert);
1882
1882
1883
1883
args.GetReturnValue ().Set (result);
1884
1884
}
Original file line number Diff line number Diff line change @@ -37,8 +37,13 @@ const server = tls
37
37
rejectUnauthorized : false
38
38
} ,
39
39
function ( ) {
40
- assert . strictEqual ( client . getCertificate ( ) . serialNumber ,
41
- 'FAD50CC6A07F516C' ) ;
40
+ for ( let i = 0 ; i < 10 ; ++ i ) {
41
+ // Calling this repeatedly is a regression test that verifies
42
+ // that .getCertificate() does not accidentally decrease the
43
+ // reference count of the X509* certificate on the native side.
44
+ assert . strictEqual ( client . getCertificate ( ) . serialNumber ,
45
+ 'FAD50CC6A07F516C' ) ;
46
+ }
42
47
client . end ( ) ;
43
48
server . close ( ) ;
44
49
}
You can’t perform that action at this time.
0 commit comments