File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed
Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,15 @@ import {
7171
7272 tlsSocket . getPeerX509Certificate ( ) ; // $ExpectType X509Certificate | undefined
7373 tlsSocket . getX509Certificate ( ) ; // $ExpectType X509Certificate | undefined
74+
75+ tlsSocket . setKeyCert ( {
76+ cert : fs . readFileSync ( "cert_filepath" ) ,
77+ key : fs . readFileSync ( "key_filepath" ) ,
78+ } ) ;
79+ tlsSocket . setKeyCert ( createSecureContext ( {
80+ key : "NOT REALLY A KEY" ,
81+ cert : "SOME CERTIFICATE" ,
82+ } ) ) ;
7483}
7584
7685{
Original file line number Diff line number Diff line change @@ -398,6 +398,14 @@ declare module "tls" {
398398 } ,
399399 callback : ( err : Error | null ) => void ,
400400 ) : undefined | boolean ;
401+ /**
402+ * The `tlsSocket.setKeyCert()` method sets the private key and certificate to use for the socket.
403+ * This is mainly useful if you wish to select a server certificate from a TLS server's `ALPNCallback`.
404+ * @since v22.5.0, v20.17.0
405+ * @param context An object containing at least `key` and `cert` properties from the {@link createSecureContext()} `options`,
406+ * or a TLS context object created with {@link createSecureContext()} itself.
407+ */
408+ setKeyCert ( context : SecureContextOptions | SecureContext ) : void ;
401409 /**
402410 * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
403411 * Returns `true` if setting the limit succeeded; `false` otherwise.
Original file line number Diff line number Diff line change @@ -69,6 +69,15 @@ import {
6969
7070 tlsSocket . getPeerX509Certificate ( ) ; // $ExpectType X509Certificate | undefined
7171 tlsSocket . getX509Certificate ( ) ; // $ExpectType X509Certificate | undefined
72+
73+ tlsSocket . setKeyCert ( {
74+ cert : fs . readFileSync ( "cert_filepath" ) ,
75+ key : fs . readFileSync ( "key_filepath" ) ,
76+ } ) ;
77+ tlsSocket . setKeyCert ( createSecureContext ( {
78+ key : "NOT REALLY A KEY" ,
79+ cert : "SOME CERTIFICATE" ,
80+ } ) ) ;
7281}
7382
7483{
Original file line number Diff line number Diff line change @@ -398,6 +398,14 @@ declare module "tls" {
398398 } ,
399399 callback : ( err : Error | null ) => void ,
400400 ) : undefined | boolean ;
401+ /**
402+ * The `tlsSocket.setKeyCert()` method sets the private key and certificate to use for the socket.
403+ * This is mainly useful if you wish to select a server certificate from a TLS server's `ALPNCallback`.
404+ * @since v22.5.0, v20.17.0
405+ * @param context An object containing at least `key` and `cert` properties from the {@link createSecureContext()} `options`,
406+ * or a TLS context object created with {@link createSecureContext()} itself.
407+ */
408+ setKeyCert ( context : SecureContextOptions | SecureContext ) : void ;
401409 /**
402410 * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
403411 * Returns `true` if setting the limit succeeded; `false` otherwise.
You can’t perform that action at this time.
0 commit comments