From 9b486e22588ad91dbcd61f12dfe1e451b03cd44e Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 29 Jun 2024 06:16:58 -0400 Subject: [PATCH] tls: add setKeyCert() to tls.Socket --- doc/api/tls.md | 14 ++++++ lib/_tls_wrap.js | 11 ++++ src/crypto/crypto_tls.cc | 28 +++++++++++ src/crypto/crypto_tls.h | 1 + test/parallel/test-tls-server-setkeycert.js | 56 +++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 test/parallel/test-tls-server-setkeycert.js diff --git a/doc/api/tls.md b/doc/api/tls.md index ed9c3a489be847..196c0525fd509b 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1533,6 +1533,20 @@ When running as the server, the socket will be destroyed with an error after For TLSv1.3, renegotiation cannot be initiated, it is not supported by the protocol. +### `tlsSocket.setKeyCert(context)` + + + +* `context` {Object|tls.SecureContext} An object containing at least `key` and + `cert` properties from the [`tls.createSecureContext()`][] `options`, or a + TLS context object created with [`tls.createSecureContext()`][] itself. + +The `tlsSocket.setKeyCert()` method sets the private key and certificate to use +for the socket. This is mainly useful if you wish to select a server certificate +from a TLS server's `ALPNCallback`. + ### `tlsSocket.setMaxSendFragment(size)`