@@ -146,6 +146,10 @@ const {
146146 isKeyObject,
147147} = require ( 'internal/crypto/keys' ) ;
148148
149+ const {
150+ InternalX509Certificate,
151+ } = require ( 'internal/crypto/x509' ) ;
152+
149153const {
150154 FileHandle,
151155 kHandle : kFileHandle ,
@@ -2989,24 +2993,37 @@ class QuicSession {
29892993 }
29902994
29912995 /**
2992- * The local certificate as an object, or undefined if not available.
2993- * @type {object|undefined }
2996+ * The local certificate as a {@link crypto.X509Certificate}, or undefined
2997+ * if no local certificate is available. Server sessions return their
2998+ * configured certificate; client sessions return undefined unless a
2999+ * client certificate was sent.
3000+ * @type {crypto.X509Certificate|undefined }
29943001 */
29953002 get certificate ( ) {
29963003 QuicSession . #assertIsQuicSession( this ) ;
29973004 if ( this . destroyed ) return undefined ;
2998- return this . #certificate ??= this . #handle. getCertificate ( ) ;
3005+ if ( this . #certificate === undefined ) {
3006+ const handle = this . #handle. getCertificate ( ) ;
3007+ this . #certificate = handle ? new InternalX509Certificate ( handle ) : null ;
3008+ }
3009+ return this . #certificate ?? undefined ;
29993010 }
30003011
30013012 /**
3002- * The peer's certificate as an object , or undefined if the peer did
3003- * not present a certificate or the session is destroyed.
3004- * @type {object |undefined }
3013+ * The peer's certificate as a { @link crypto.X509Certificate} , or undefined
3014+ * if the peer did not present a certificate or the session is destroyed.
3015+ * @type {crypto.X509Certificate |undefined }
30053016 */
30063017 get peerCertificate ( ) {
30073018 QuicSession . #assertIsQuicSession( this ) ;
30083019 if ( this . destroyed ) return undefined ;
3009- return this . #peerCertificate ??= this . #handle. getPeerCertificate ( ) ;
3020+ if ( this . #peerCertificate === undefined ) {
3021+ const handle = this . #handle. getPeerCertificate ( ) ;
3022+ this . #peerCertificate = handle ?
3023+ new InternalX509Certificate ( handle ) :
3024+ null ;
3025+ }
3026+ return this . #peerCertificate ?? undefined ;
30103027 }
30113028
30123029 /**
0 commit comments