{
  "type": "module",
  "source": "doc/api/tls.md",
  "modules": [
    {
      "textRaw": "TLS (SSL)",
      "name": "tls_(ssl)",
      "introduced_in": "v0.10.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>The <code>node:tls</code> module provides an implementation of the Transport Layer Security\n(TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL.\nThe module can be accessed using:</p>\n<pre><code class=\"language-mjs\">import tls from 'node:tls';\n</code></pre>\n<pre><code class=\"language-cjs\">const tls = require('node:tls');\n</code></pre>",
      "modules": [
        {
          "textRaw": "Determining if crypto support is unavailable",
          "name": "determining_if_crypto_support_is_unavailable",
          "type": "module",
          "desc": "<p>It is possible for Node.js to be built without including support for the\n<code>node:crypto</code> module. In such cases, attempting to <code>import</code> from <code>tls</code> or\ncalling <code>require('node:tls')</code> will result in an error being thrown.</p>\n<p>When using CommonJS, the error thrown can be caught using try/catch:</p>\n<pre><code class=\"language-cjs\">let tls;\ntry {\n  tls = require('node:tls');\n} catch (err) {\n  console.error('tls support is disabled!');\n}\n</code></pre>\n<p>When using the lexical ESM <code>import</code> keyword, the error can only be\ncaught if a handler for <code>process.on('uncaughtException')</code> is registered\n<em>before</em> any attempt to load the module is made (using, for instance,\na preload module).</p>\n<p>When using ESM, if there is a chance that the code may be run on a build\nof Node.js where crypto support is not enabled, consider using the\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import\"><code>import()</code></a> function instead of the lexical <code>import</code> keyword:</p>\n<pre><code class=\"language-mjs\">let tls;\ntry {\n  tls = await import('node:tls');\n} catch (err) {\n  console.error('tls support is disabled!');\n}\n</code></pre>",
          "displayName": "Determining if crypto support is unavailable"
        },
        {
          "textRaw": "TLS/SSL concepts",
          "name": "tls/ssl_concepts",
          "type": "module",
          "desc": "<p>TLS/SSL is a set of protocols that rely on a public key infrastructure (PKI) to\nenable secure communication between a client and a server. For most common\ncases, each server must have a private key.</p>\n<p>Private keys can be generated in multiple ways. The example below illustrates\nuse of the OpenSSL command-line interface to generate a 2048-bit RSA private\nkey:</p>\n<pre><code class=\"language-bash\">openssl genrsa -out ryans-key.pem 2048\n</code></pre>\n<p>With TLS/SSL, all servers (and some clients) must have a <em>certificate</em>.\nCertificates are <em>public keys</em> that correspond to a private key, and that are\ndigitally signed either by a Certificate Authority or by the owner of the\nprivate key (such certificates are referred to as \"self-signed\"). The first\nstep to obtaining a certificate is to create a <em>Certificate Signing Request</em>\n(CSR) file.</p>\n<p>The OpenSSL command-line interface can be used to generate a CSR for a private\nkey:</p>\n<pre><code class=\"language-bash\">openssl req -new -sha256 -key ryans-key.pem -out ryans-csr.pem\n</code></pre>\n<p>Once the CSR file is generated, it can either be sent to a Certificate\nAuthority for signing or used to generate a self-signed certificate.</p>\n<p>Creating a self-signed certificate using the OpenSSL command-line interface\nis illustrated in the example below:</p>\n<pre><code class=\"language-bash\">openssl x509 -req -in ryans-csr.pem -signkey ryans-key.pem -out ryans-cert.pem\n</code></pre>\n<p>Once the certificate is generated, it can be used to generate a <code>.pfx</code> or\n<code>.p12</code> file:</p>\n<pre><code class=\"language-bash\">openssl pkcs12 -export -in ryans-cert.pem -inkey ryans-key.pem \\\n      -certfile ca-cert.pem -out ryans.pfx\n</code></pre>\n<p>Where:</p>\n<ul>\n<li><code>in</code>: is the signed certificate</li>\n<li><code>inkey</code>: is the associated private key</li>\n<li><code>certfile</code>: is a concatenation of all Certificate Authority (CA) certs into\na single file, e.g. <code>cat ca1-cert.pem ca2-cert.pem > ca-cert.pem</code></li>\n</ul>",
          "miscs": [
            {
              "textRaw": "Perfect forward secrecy",
              "name": "Perfect forward secrecy",
              "type": "misc",
              "desc": "<p>The term <em><a href=\"https://en.wikipedia.org/wiki/Perfect_forward_secrecy\">forward secrecy</a></em> or <em>perfect forward secrecy</em> describes a feature\nof key-agreement (i.e., key-exchange) methods. That is, the server and client\nkeys are used to negotiate new temporary keys that are used specifically and\nonly for the current communication session. Practically, this means that even\nif the server's private key is compromised, communication can only be decrypted\nby eavesdroppers if the attacker manages to obtain the key-pair specifically\ngenerated for the session.</p>\n<p>Perfect forward secrecy is achieved by randomly generating a key pair for\nkey-agreement on every TLS/SSL handshake (in contrast to using the same key for\nall sessions). Methods implementing this technique are called \"ephemeral\".</p>\n<p>Currently two methods are commonly used to achieve perfect forward secrecy (note\nthe character \"E\" appended to the traditional abbreviations):</p>\n<ul>\n<li><a href=\"https://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman\">ECDHE</a>: An ephemeral version of the Elliptic Curve Diffie-Hellman\nkey-agreement protocol.</li>\n<li><a href=\"https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange\">DHE</a>: An ephemeral version of the Diffie-Hellman key-agreement protocol.</li>\n</ul>\n<p>Perfect forward secrecy using ECDHE is enabled by default. The <code>ecdhCurve</code>\noption can be used when creating a TLS server to customize the list of supported\nECDH curves to use. See <a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a> for more info.</p>\n<p>DHE is disabled by default but can be enabled alongside ECDHE by setting the\n<code>dhparam</code> option to <code>'auto'</code>. Custom DHE parameters are also supported but\ndiscouraged in favor of automatically selected, well-known parameters.</p>\n<p>Perfect forward secrecy was optional up to TLSv1.2. As of TLSv1.3, (EC)DHE is\nalways used (with the exception of PSK-only connections).</p>"
            },
            {
              "textRaw": "ALPN and SNI",
              "name": "ALPN and SNI",
              "type": "misc",
              "desc": "<p>ALPN (Application-Layer Protocol Negotiation Extension) and\nSNI (Server Name Indication) are TLS handshake extensions:</p>\n<ul>\n<li>ALPN: Allows the use of one TLS server for multiple protocols (HTTP, HTTP/2)</li>\n<li>SNI: Allows the use of one TLS server for multiple hostnames with different\ncertificates.</li>\n</ul>"
            },
            {
              "textRaw": "Pre-shared keys",
              "name": "Pre-shared keys",
              "type": "misc",
              "desc": "<p>TLS-PSK support is available as an alternative to normal certificate-based\nauthentication. It uses a pre-shared key instead of certificates to\nauthenticate a TLS connection, providing mutual authentication.\nTLS-PSK and public key infrastructure are not mutually exclusive. Clients and\nservers can accommodate both, choosing either of them during the normal cipher\nnegotiation step.</p>\n<p>TLS-PSK is only a good choice where means exist to securely share a\nkey with every connecting machine, so it does not replace the public key\ninfrastructure (PKI) for the majority of TLS uses.\nThe TLS-PSK implementation in OpenSSL has seen many security flaws in\nrecent years, mostly because it is used only by a minority of applications.\nPlease consider all alternative solutions before switching to PSK ciphers.\nUpon generating PSK it is of critical importance to use sufficient entropy as\ndiscussed in <a href=\"https://tools.ietf.org/html/rfc4086\">RFC 4086</a>. Deriving a shared secret from a password or other\nlow-entropy sources is not secure.</p>\n<p>PSK ciphers are disabled by default, and using TLS-PSK thus requires explicitly\nspecifying a cipher suite with the <code>ciphers</code> option. The list of available\nciphers can be retrieved via <code>openssl ciphers -v 'PSK'</code>. All TLS 1.3\nciphers are eligible for PSK and can be retrieved via\n<code>openssl ciphers -v -s -tls1_3 -psk</code>.\nOn the client connection, a custom <code>checkServerIdentity</code> should be passed\nbecause the default one will fail in the absence of a certificate.</p>\n<p>According to the <a href=\"https://tools.ietf.org/html/rfc4279\">RFC 4279</a>, PSK identities up to 128 bytes in length and\nPSKs up to 64 bytes in length must be supported. As of OpenSSL 1.1.0\nmaximum identity size is 128 bytes, and maximum PSK length is 256 bytes.</p>\n<p>The current implementation doesn't support asynchronous PSK callbacks due to the\nlimitations of the underlying OpenSSL API.</p>\n<p>To use TLS-PSK, client and server must specify the <code>pskCallback</code> option,\na function that returns the PSK to use (which must be compatible with\nthe selected cipher's digest).</p>\n<p>It will be called first on the client:</p>\n<ul>\n<li><code>hint</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> optional message sent from the server to help the client\ndecide which identity to use during negotiation.\nAlways <code>null</code> if TLS 1.3 is used.</li>\n<li>Returns: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> in the form <code>{ psk: &#x3C;Buffer|TypedArray|DataView>, identity: &#x3C;string> }</code> or <code>null</code>.</li>\n</ul>\n<p>Then on the server:</p>\n<ul>\n<li><code>socket</code> <a href=\"tls.html#tlstlssocket\"><code>&#x3C;tls.TLSSocket></code></a> the server socket instance, equivalent to <code>this</code>.</li>\n<li><code>identity</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> identity parameter sent from the client.</li>\n<li>Returns: <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\"><code>&#x3C;TypedArray></code></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView\"><code>&#x3C;DataView></code></a> the PSK (or <code>null</code>).</li>\n</ul>\n<p>A return value of <code>null</code> stops the negotiation process and sends an\n<code>unknown_psk_identity</code> alert message to the other party.\nIf the server wishes to hide the fact that the PSK identity was not known,\nthe callback must provide some random data as <code>psk</code> to make the connection\nfail with <code>decrypt_error</code> before negotiation is finished.</p>"
            },
            {
              "textRaw": "Client-initiated renegotiation attack mitigation",
              "name": "Client-initiated renegotiation attack mitigation",
              "type": "misc",
              "desc": "<p>The TLS protocol allows clients to renegotiate certain aspects of the TLS\nsession. Unfortunately, session renegotiation requires a disproportionate amount\nof server-side resources, making it a potential vector for denial-of-service\nattacks.</p>\n<p>To mitigate the risk, renegotiation is limited to three times every ten minutes.\nAn <code>'error'</code> event is emitted on the <a href=\"#class-tlstlssocket\"><code>tls.TLSSocket</code></a> instance when this\nthreshold is exceeded. The limits are configurable:</p>\n<ul>\n<li><code>tls.CLIENT_RENEG_LIMIT</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> Specifies the number of renegotiation\nrequests. <strong>Default:</strong> <code>3</code>.</li>\n<li><code>tls.CLIENT_RENEG_WINDOW</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> Specifies the time renegotiation window\nin seconds. <strong>Default:</strong> <code>600</code> (10 minutes).</li>\n</ul>\n<p>The default renegotiation limits should not be modified without a full\nunderstanding of the implications and risks.</p>\n<p>TLSv1.3 does not support renegotiation.</p>"
            }
          ],
          "modules": [
            {
              "textRaw": "Session resumption",
              "name": "session_resumption",
              "type": "module",
              "desc": "<p>Establishing a TLS session can be relatively slow. The process can be sped\nup by saving and later reusing the session state. There are several mechanisms\nto do so, discussed here from oldest to newest (and preferred).</p>",
              "modules": [
                {
                  "textRaw": "Session identifiers",
                  "name": "session_identifiers",
                  "type": "module",
                  "desc": "<p>Servers generate a unique ID for new connections and\nsend it to the client. Clients and servers save the session state. When\nreconnecting, clients send the ID of their saved session state and if the server\nalso has the state for that ID, it can agree to use it. Otherwise, the server\nwill create a new session. See <a href=\"https://www.ietf.org/rfc/rfc2246.txt\">RFC 2246</a> for more information, page 23 and\n30.</p>\n<p>Resumption using session identifiers is supported by most web browsers when\nmaking HTTPS requests.</p>\n<p>For Node.js, clients wait for the <a href=\"#event-session\"><code>'session'</code></a> event to get the session data,\nand provide the data to the <code>session</code> option of a subsequent <a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a>\nto reuse the session. Servers must\nimplement handlers for the <a href=\"#event-newsession\"><code>'newSession'</code></a> and <a href=\"#event-resumesession\"><code>'resumeSession'</code></a> events\nto save and restore the session data using the session ID as the lookup key to\nreuse sessions. To reuse sessions across load balancers or cluster workers,\nservers must use a shared session cache (such as Redis) in their session\nhandlers.</p>",
                  "displayName": "Session identifiers"
                },
                {
                  "textRaw": "Session tickets",
                  "name": "session_tickets",
                  "type": "module",
                  "desc": "<p>The servers encrypt the entire session state and send it\nto the client as a \"ticket\". When reconnecting, the state is sent to the server\nin the initial connection. This mechanism avoids the need for a server-side\nsession cache. If the server doesn't use the ticket, for any reason (failure\nto decrypt it, it's too old, etc.), it will create a new session and send a new\nticket. See <a href=\"https://tools.ietf.org/html/rfc5077\">RFC 5077</a> for more information.</p>\n<p>Resumption using session tickets is becoming commonly supported by many web\nbrowsers when making HTTPS requests.</p>\n<p>For Node.js, clients use the same APIs for resumption with session identifiers\nas for resumption with session tickets. For debugging, if\n<a href=\"#tlssocketgettlsticket\"><code>tls.TLSSocket.getTLSTicket()</code></a> returns a value, the session data contains a\nticket, otherwise it contains client-side session state.</p>\n<p>With TLSv1.3, be aware that multiple tickets may be sent by the server,\nresulting in multiple <code>'session'</code> events, see <a href=\"#event-session\"><code>'session'</code></a> for more\ninformation.</p>\n<p>Single process servers need no specific implementation to use session tickets.\nTo use session tickets across server restarts or load balancers, servers must\nall have the same ticket keys. There are three 16-byte keys internally, but the\ntls API exposes them as a single 48-byte buffer for convenience.</p>\n<p>It's possible to get the ticket keys by calling <a href=\"#servergetticketkeys\"><code>server.getTicketKeys()</code></a> on\none server instance and then distribute them, but it is more reasonable to\nsecurely generate 48 bytes of secure random data and set them with the\n<code>ticketKeys</code> option of <a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a>. The keys should be regularly\nregenerated and server's keys can be reset with\n<a href=\"#serversetticketkeyskeys\"><code>server.setTicketKeys()</code></a>.</p>\n<p>Session ticket keys are cryptographic keys, and they <em><strong>must be stored\nsecurely</strong></em>. With TLS 1.2 and below, if they are compromised all sessions that\nused tickets encrypted with them can be decrypted. They should not be stored\non disk, and they should be regenerated regularly.</p>\n<p>If clients advertise support for tickets, the server will send them. The\nserver can disable tickets by supplying\n<code>require('node:constants').SSL_OP_NO_TICKET</code> in <code>secureOptions</code>.</p>\n<p>Both session identifiers and session tickets timeout, causing the server to\ncreate new sessions. The timeout can be configured with the <code>sessionTimeout</code>\noption of <a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a>.</p>\n<p>For all the mechanisms, when resumption fails, servers will create new sessions.\nSince failing to resume the session does not cause TLS/HTTPS connection\nfailures, it is easy to not notice unnecessarily poor TLS performance. The\nOpenSSL CLI can be used to verify that servers are resuming sessions. Use the\n<code>-reconnect</code> option to <code>openssl s_client</code>, for example:</p>\n<pre><code class=\"language-bash\">openssl s_client -connect localhost:443 -reconnect\n</code></pre>\n<p>Read through the debug output. The first connection should say \"New\", for\nexample:</p>\n<pre><code class=\"language-text\">New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256\n</code></pre>\n<p>Subsequent connections should say \"Reused\", for example:</p>\n<pre><code class=\"language-text\">Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256\n</code></pre>",
                  "displayName": "Session tickets"
                }
              ],
              "displayName": "Session resumption"
            }
          ],
          "displayName": "TLS/SSL concepts"
        },
        {
          "textRaw": "Modifying the default TLS cipher suite",
          "name": "modifying_the_default_tls_cipher_suite",
          "type": "module",
          "desc": "<p>Node.js is built with a default suite of enabled and disabled TLS ciphers. This\ndefault cipher list can be configured when building Node.js to allow\ndistributions to provide their own default list.</p>\n<p>The following command can be used to show the default cipher suite:</p>\n<pre><code class=\"language-console\">node -p crypto.constants.defaultCoreCipherList | tr ':' '\\n'\nTLS_AES_256_GCM_SHA384\nTLS_CHACHA20_POLY1305_SHA256\nTLS_AES_128_GCM_SHA256\nECDHE-RSA-AES128-GCM-SHA256\nECDHE-ECDSA-AES128-GCM-SHA256\nECDHE-RSA-AES256-GCM-SHA384\nECDHE-ECDSA-AES256-GCM-SHA384\nDHE-RSA-AES128-GCM-SHA256\nECDHE-RSA-AES128-SHA256\nDHE-RSA-AES128-SHA256\nECDHE-RSA-AES256-SHA384\nDHE-RSA-AES256-SHA384\nECDHE-RSA-AES256-SHA256\nDHE-RSA-AES256-SHA256\nHIGH\n!aNULL\n!eNULL\n!EXPORT\n!DES\n!RC4\n!MD5\n!PSK\n!SRP\n!CAMELLIA\n</code></pre>\n<p>This default can be replaced entirely using the <a href=\"cli.html#--tls-cipher-listlist\"><code>--tls-cipher-list</code></a>\ncommand-line switch (directly, or via the <a href=\"cli.html#node_optionsoptions\"><code>NODE_OPTIONS</code></a> environment\nvariable). For instance, the following makes <code>ECDHE-RSA-AES128-GCM-SHA256:!RC4</code>\nthe default TLS cipher suite:</p>\n<pre><code class=\"language-bash\">node --tls-cipher-list='ECDHE-RSA-AES128-GCM-SHA256:!RC4' server.js\n\nexport NODE_OPTIONS=--tls-cipher-list='ECDHE-RSA-AES128-GCM-SHA256:!RC4'\nnode server.js\n</code></pre>\n<p>To verify, use the following command to show the set cipher list, note the\ndifference between <code>defaultCoreCipherList</code> and <code>defaultCipherList</code>:</p>\n<pre><code class=\"language-bash\">node --tls-cipher-list='ECDHE-RSA-AES128-GCM-SHA256:!RC4' -p crypto.constants.defaultCipherList | tr ':' '\\n'\nECDHE-RSA-AES128-GCM-SHA256\n!RC4\n</code></pre>\n<p>i.e. the <code>defaultCoreCipherList</code> list is set at compilation time and the\n<code>defaultCipherList</code> is set at runtime.</p>\n<p>To modify the default cipher suites from within the runtime, modify the\n<code>tls.DEFAULT_CIPHERS</code> variable, this must be performed before listening on any\nsockets, it will not affect sockets already opened. For example:</p>\n<pre><code class=\"language-js\">// Remove Obsolete CBC Ciphers and RSA Key Exchange based Ciphers as they don't provide Forward Secrecy\ntls.DEFAULT_CIPHERS +=\n  ':!ECDHE-RSA-AES128-SHA:!ECDHE-RSA-AES128-SHA256:!ECDHE-RSA-AES256-SHA:!ECDHE-RSA-AES256-SHA384' +\n  ':!ECDHE-ECDSA-AES128-SHA:!ECDHE-ECDSA-AES128-SHA256:!ECDHE-ECDSA-AES256-SHA:!ECDHE-ECDSA-AES256-SHA384' +\n  ':!kRSA';\n</code></pre>\n<p>The default can also be replaced on a per client or server basis using the\n<code>ciphers</code> option from <a href=\"#tlscreatesecurecontextoptions\"><code>tls.createSecureContext()</code></a>, which is also available\nin <a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a>, <a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a>, and when creating new\n<a href=\"#class-tlstlssocket\"><code>tls.TLSSocket</code></a>s.</p>\n<p>The ciphers list can contain a mixture of TLSv1.3 cipher suite names, the ones\nthat start with <code>'TLS_'</code>, and specifications for TLSv1.2 and below cipher\nsuites. The TLSv1.2 ciphers support a legacy specification format, consult\nthe OpenSSL <a href=\"https://www.openssl.org/docs/man1.1.1/man1/ciphers.html#CIPHER-LIST-FORMAT\">cipher list format</a> documentation for details, but those\nspecifications do <em>not</em> apply to TLSv1.3 ciphers. The TLSv1.3 suites can only\nbe enabled by including their full name in the cipher list. They cannot, for\nexample, be enabled or disabled by using the legacy TLSv1.2 <code>'EECDH'</code> or\n<code>'!EECDH'</code> specification.</p>\n<p>Despite the relative order of TLSv1.3 and TLSv1.2 cipher suites, the TLSv1.3\nprotocol is significantly more secure than TLSv1.2, and will always be chosen\nover TLSv1.2 if the handshake indicates it is supported, and if any TLSv1.3\ncipher suites are enabled.</p>\n<p>The default cipher suite included within Node.js has been carefully\nselected to reflect current security best practices and risk mitigation.\nChanging the default cipher suite can have a significant impact on the security\nof an application. The <code>--tls-cipher-list</code> switch and <code>ciphers</code> option should by\nused only if absolutely necessary.</p>\n<p>The default cipher suite prefers GCM ciphers for <a href=\"https://www.chromium.org/Home/chromium-security/education/tls#TOC-Cipher-Suites\">Chrome's 'modern\ncryptography' setting</a> and also prefers ECDHE and DHE ciphers for perfect\nforward secrecy, while offering <em>some</em> backward compatibility.</p>\n<p>Old clients that rely on insecure and deprecated RC4 or DES-based ciphers\n(like Internet Explorer 6) cannot complete the handshaking process with\nthe default configuration. If these clients <em>must</em> be supported, the\n<a href=\"https://wiki.mozilla.org/Security/Server_Side_TLS\">TLS recommendations</a> may offer a compatible cipher suite. For more details\non the format, see the OpenSSL <a href=\"https://www.openssl.org/docs/man1.1.1/man1/ciphers.html#CIPHER-LIST-FORMAT\">cipher list format</a> documentation.</p>\n<p>There are only five TLSv1.3 cipher suites:</p>\n<ul>\n<li><code>'TLS_AES_256_GCM_SHA384'</code></li>\n<li><code>'TLS_CHACHA20_POLY1305_SHA256'</code></li>\n<li><code>'TLS_AES_128_GCM_SHA256'</code></li>\n<li><code>'TLS_AES_128_CCM_SHA256'</code></li>\n<li><code>'TLS_AES_128_CCM_8_SHA256'</code></li>\n</ul>\n<p>The first three are enabled by default. The two <code>CCM</code>-based suites are supported\nby TLSv1.3 because they may be more performant on constrained systems, but they\nare not enabled by default since they offer less security.</p>",
          "displayName": "Modifying the default TLS cipher suite"
        },
        {
          "textRaw": "OpenSSL security level",
          "name": "openssl_security_level",
          "type": "module",
          "desc": "<p>The OpenSSL library enforces security levels to control the minimum acceptable\nlevel of security for cryptographic operations. OpenSSL's security levels range\nfrom 0 to 5, with each level imposing stricter security requirements. The default\nsecurity level is 2, which is generally suitable for most modern applications.\nHowever, some legacy features and protocols, such as TLSv1, require a lower\nsecurity level (<code>SECLEVEL=0</code>) to function properly. For more detailed information,\nplease refer to the <a href=\"https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html#DEFAULT-CALLBACK-BEHAVIOUR\">OpenSSL documentation on security levels</a>.</p>",
          "modules": [
            {
              "textRaw": "Setting security levels",
              "name": "setting_security_levels",
              "type": "module",
              "desc": "<p>To adjust the security level in your Node.js application, you can include <code>@SECLEVEL=X</code>\nwithin a cipher string, where <code>X</code> is the desired security level. For example,\nto set the security level to 0 while using the default OpenSSL cipher list, you could use:</p>\n<pre><code class=\"language-mjs\">import { createServer, connect } from 'node:tls';\nconst port = 443;\n\ncreateServer({ ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1' }, function(socket) {\n  console.log('Client connected with protocol:', socket.getProtocol());\n  socket.end();\n  this.close();\n})\n.listen(port, () => {\n  connect(port, { ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1' });\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { createServer, connect } = require('node:tls');\nconst port = 443;\n\ncreateServer({ ciphers: 'DEFAULT@SECLEVEL=0', minVersion: 'TLSv1' }, function(socket) {\n  console.log('Client connected with protocol:', socket.getProtocol());\n  socket.end();\n  this.close();\n})\n.listen(port, () => {\n  connect(port, { ciphers: 'DEFAULT@SECLEVEL=0', maxVersion: 'TLSv1' });\n});\n</code></pre>\n<p>This approach sets the security level to 0, allowing the use of legacy features while still\nleveraging the default OpenSSL ciphers.</p>",
              "displayName": "Setting security levels"
            },
            {
              "textRaw": "Using `--tls-cipher-list`",
              "name": "using_`--tls-cipher-list`",
              "type": "module",
              "desc": "<p>You can also set the security level and ciphers from the command line using the\n<code>--tls-cipher-list=DEFAULT@SECLEVEL=X</code> as described in <a href=\"#modifying-the-default-tls-cipher-suite\">Modifying the default TLS cipher suite</a>.\nHowever, it is generally discouraged to use the command line option for setting ciphers and it is\npreferable to configure the ciphers for individual contexts within your application code,\nas this approach provides finer control and reduces the risk of globally downgrading the security level.</p>",
              "displayName": "Using `--tls-cipher-list`"
            }
          ],
          "displayName": "OpenSSL security level"
        },
        {
          "textRaw": "X509 certificate error codes",
          "name": "x509_certificate_error_codes",
          "type": "module",
          "desc": "<p>Multiple functions can fail due to certificate errors that are reported by\nOpenSSL. In such a case, the function provides an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></a> via its callback that\nhas the property <code>code</code> which can take one of the following values:</p>\n<!--\nvalues are taken from src/crypto/crypto_common.cc\ndescription are taken from deps/openssl/openssl/crypto/x509/x509_txt.c\n-->\n<ul>\n<li><code>'UNABLE_TO_GET_ISSUER_CERT'</code>: Unable to get issuer certificate.</li>\n<li><code>'UNABLE_TO_GET_CRL'</code>: Unable to get certificate CRL.</li>\n<li><code>'UNABLE_TO_DECRYPT_CERT_SIGNATURE'</code>: Unable to decrypt certificate's\nsignature.</li>\n<li><code>'UNABLE_TO_DECRYPT_CRL_SIGNATURE'</code>: Unable to decrypt CRL's signature.</li>\n<li><code>'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY'</code>: Unable to decode issuer public key.</li>\n<li><code>'CERT_SIGNATURE_FAILURE'</code>: Certificate signature failure.</li>\n<li><code>'CRL_SIGNATURE_FAILURE'</code>: CRL signature failure.</li>\n<li><code>'CERT_NOT_YET_VALID'</code>: Certificate is not yet valid.</li>\n<li><code>'CERT_HAS_EXPIRED'</code>: Certificate has expired.</li>\n<li><code>'CRL_NOT_YET_VALID'</code>: CRL is not yet valid.</li>\n<li><code>'CRL_HAS_EXPIRED'</code>: CRL has expired.</li>\n<li><code>'ERROR_IN_CERT_NOT_BEFORE_FIELD'</code>: Format error in certificate's notBefore\nfield.</li>\n<li><code>'ERROR_IN_CERT_NOT_AFTER_FIELD'</code>: Format error in certificate's notAfter\nfield.</li>\n<li><code>'ERROR_IN_CRL_LAST_UPDATE_FIELD'</code>: Format error in CRL's lastUpdate field.</li>\n<li><code>'ERROR_IN_CRL_NEXT_UPDATE_FIELD'</code>: Format error in CRL's nextUpdate field.</li>\n<li><code>'OUT_OF_MEM'</code>: Out of memory.</li>\n<li><code>'DEPTH_ZERO_SELF_SIGNED_CERT'</code>: Self signed certificate.</li>\n<li><code>'SELF_SIGNED_CERT_IN_CHAIN'</code>: Self signed certificate in certificate chain.</li>\n<li><code>'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'</code>: Unable to get local issuer certificate.</li>\n<li><code>'UNABLE_TO_VERIFY_LEAF_SIGNATURE'</code>: Unable to verify the first certificate.</li>\n<li><code>'CERT_CHAIN_TOO_LONG'</code>: Certificate chain too long.</li>\n<li><code>'CERT_REVOKED'</code>: Certificate revoked.</li>\n<li><code>'INVALID_CA'</code>: Invalid CA certificate.</li>\n<li><code>'PATH_LENGTH_EXCEEDED'</code>: Path length constraint exceeded.</li>\n<li><code>'INVALID_PURPOSE'</code>: Unsupported certificate purpose.</li>\n<li><code>'CERT_UNTRUSTED'</code>: Certificate not trusted.</li>\n<li><code>'CERT_REJECTED'</code>: Certificate rejected.</li>\n<li><code>'HOSTNAME_MISMATCH'</code>: Hostname mismatch.</li>\n</ul>\n<p>When certificate errors like <code>UNABLE_TO_VERIFY_LEAF_SIGNATURE</code>,\n<code>DEPTH_ZERO_SELF_SIGNED_CERT</code>, or <code>UNABLE_TO_GET_ISSUER_CERT</code> occur, Node.js\nappends a hint suggesting that if the root CA is installed locally,\ntry running with the <code>--use-system-ca</code> flag to direct developers towards a\nsecure solution, to prevent unsafe workarounds.</p>",
          "displayName": "X509 certificate error codes"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `tls.Server`",
          "name": "tls.Server",
          "type": "class",
          "meta": {
            "added": [
              "v0.3.2"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"net.html#class-netserver\"><code>&#x3C;net.Server></code></a></li>\n</ul>\n<p>Accepts encrypted connections using TLS or SSL.</p>",
          "events": [
            {
              "textRaw": "Event: `'connection'`",
              "name": "connection",
              "type": "event",
              "meta": {
                "added": [
                  "v0.3.2"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`socket` {stream.Duplex}",
                  "name": "socket",
                  "type": "stream.Duplex"
                }
              ],
              "desc": "<p>This event is emitted when a new TCP stream is established, before the TLS\nhandshake begins. <code>socket</code> is typically an object of type <a href=\"net.html#class-netsocket\"><code>net.Socket</code></a> but\nwill not receive events unlike the socket created from the <a href=\"net.html#class-netserver\"><code>net.Server</code></a>\n<code>'connection'</code> event. Usually users will not want to access this event.</p>\n<p>This event can also be explicitly emitted by users to inject connections\ninto the TLS server. In that case, any <a href=\"stream.html#class-streamduplex\"><code>Duplex</code></a> stream can be passed.</p>"
            },
            {
              "textRaw": "Event: `'keylog'`",
              "name": "keylog",
              "type": "event",
              "meta": {
                "added": [
                  "v12.3.0",
                  "v10.20.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`line` {Buffer} Line of ASCII text, in NSS `SSLKEYLOGFILE` format.",
                  "name": "line",
                  "type": "Buffer",
                  "desc": "Line of ASCII text, in NSS `SSLKEYLOGFILE` format."
                },
                {
                  "textRaw": "`tlsSocket` {tls.TLSSocket} The `tls.TLSSocket` instance on which it was generated.",
                  "name": "tlsSocket",
                  "type": "tls.TLSSocket",
                  "desc": "The `tls.TLSSocket` instance on which it was generated."
                }
              ],
              "desc": "<p>The <code>keylog</code> event is emitted when key material is generated or received by\na connection to this server (typically before handshake has completed, but not\nnecessarily). This keying material can be stored for debugging, as it allows\ncaptured TLS traffic to be decrypted. It may be emitted multiple times for\neach socket.</p>\n<p>A typical use case is to append received lines to a common text file, which\nis later used by software (such as Wireshark) to decrypt the traffic:</p>\n<pre><code class=\"language-js\">const logFile = fs.createWriteStream('/tmp/ssl-keys.log', { flags: 'a' });\n// ...\nserver.on('keylog', (line, tlsSocket) => {\n  if (tlsSocket.remoteAddress !== '...')\n    return; // Only log keys for a particular IP\n  logFile.write(line);\n});\n</code></pre>"
            },
            {
              "textRaw": "Event: `'newSession'`",
              "name": "newSession",
              "type": "event",
              "meta": {
                "added": [
                  "v0.9.2"
                ],
                "changes": [
                  {
                    "version": "v0.11.12",
                    "pr-url": "https://github.com/nodejs/node-v0.x-archive/pull/7118",
                    "description": "The `callback` argument is now supported."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`sessionId` {Buffer} The TLS session identifier",
                  "name": "sessionId",
                  "type": "Buffer",
                  "desc": "The TLS session identifier"
                },
                {
                  "textRaw": "`sessionData` {Buffer} The TLS session data",
                  "name": "sessionData",
                  "type": "Buffer",
                  "desc": "The TLS session data"
                },
                {
                  "textRaw": "`callback` {Function} A callback function taking no arguments that must be invoked in order for data to be sent or received over the secure connection.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "A callback function taking no arguments that must be invoked in order for data to be sent or received over the secure connection."
                }
              ],
              "desc": "<p>The <code>'newSession'</code> event is emitted upon creation of a new TLS session. This may\nbe used to store sessions in external storage. The data should be provided to\nthe <a href=\"#event-resumesession\"><code>'resumeSession'</code></a> callback.</p>\n<p>The listener callback is passed three arguments when called:</p>\n<p>Listening for this event will have an effect only on connections established\nafter the addition of the event listener.</p>"
            },
            {
              "textRaw": "Event: `'OCSPRequest'`",
              "name": "OCSPRequest",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.13"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`certificate` {Buffer} The server certificate",
                  "name": "certificate",
                  "type": "Buffer",
                  "desc": "The server certificate"
                },
                {
                  "textRaw": "`issuer` {Buffer} The issuer's certificate",
                  "name": "issuer",
                  "type": "Buffer",
                  "desc": "The issuer's certificate"
                },
                {
                  "textRaw": "`callback` {Function} A callback function that must be invoked to provide the results of the OCSP request.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "A callback function that must be invoked to provide the results of the OCSP request."
                }
              ],
              "desc": "<p>The <code>'OCSPRequest'</code> event is emitted when the client sends a certificate status\nrequest. The listener callback is passed three arguments when called:</p>\n<p>The server's current certificate can be parsed to obtain the OCSP URL\nand certificate ID; after obtaining an OCSP response, <code>callback(null, resp)</code> is\nthen invoked, where <code>resp</code> is a <code>Buffer</code> instance containing the OCSP response.\nBoth <code>certificate</code> and <code>issuer</code> are <code>Buffer</code> DER-representations of the\nprimary and issuer's certificates. These can be used to obtain the OCSP\ncertificate ID and OCSP endpoint URL.</p>\n<p>Alternatively, <code>callback(null, null)</code> may be called, indicating that there was\nno OCSP response.</p>\n<p>Calling <code>callback(err)</code> will result in a <code>socket.destroy(err)</code> call.</p>\n<p>The typical flow of an OCSP request is as follows:</p>\n<ol>\n<li>Client connects to the server and sends an <code>'OCSPRequest'</code> (via the status\ninfo extension in ClientHello).</li>\n<li>Server receives the request and emits the <code>'OCSPRequest'</code> event, calling the\nlistener if registered.</li>\n<li>Server extracts the OCSP URL from either the <code>certificate</code> or <code>issuer</code> and\nperforms an <a href=\"https://en.wikipedia.org/wiki/OCSP_stapling\">OCSP request</a> to the CA.</li>\n<li>Server receives <code>'OCSPResponse'</code> from the CA and sends it back to the client\nvia the <code>callback</code> argument</li>\n<li>Client validates the response and either destroys the socket or performs a\nhandshake.</li>\n</ol>\n<p>The <code>issuer</code> can be <code>null</code> if the certificate is either self-signed or the\nissuer is not in the root certificates list. (An issuer may be provided\nvia the <code>ca</code> option when establishing the TLS connection.)</p>\n<p>Listening for this event will have an effect only on connections established\nafter the addition of the event listener.</p>\n<p>An npm module like <a href=\"https://www.npmjs.com/package/asn1.js\">asn1.js</a> may be used to parse the certificates.</p>"
            },
            {
              "textRaw": "Event: `'resumeSession'`",
              "name": "resumeSession",
              "type": "event",
              "meta": {
                "added": [
                  "v0.9.2"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`sessionId` {Buffer} The TLS session identifier",
                  "name": "sessionId",
                  "type": "Buffer",
                  "desc": "The TLS session identifier"
                },
                {
                  "textRaw": "`callback` {Function} A callback function to be called when the prior session has been recovered: `callback([err[, sessionData]])`",
                  "name": "callback",
                  "type": "Function",
                  "desc": "A callback function to be called when the prior session has been recovered: `callback([err[, sessionData]])`",
                  "options": [
                    {
                      "textRaw": "`err` {Error}",
                      "name": "err",
                      "type": "Error"
                    },
                    {
                      "textRaw": "`sessionData` {Buffer}",
                      "name": "sessionData",
                      "type": "Buffer"
                    }
                  ]
                }
              ],
              "desc": "<p>The <code>'resumeSession'</code> event is emitted when the client requests to resume a\nprevious TLS session. The listener callback is passed two arguments when\ncalled:</p>\n<p>The event listener should perform a lookup in external storage for the\n<code>sessionData</code> saved by the <a href=\"#event-newsession\"><code>'newSession'</code></a> event handler using the given\n<code>sessionId</code>. If found, call <code>callback(null, sessionData)</code> to resume the session.\nIf not found, the session cannot be resumed. <code>callback()</code> must be called\nwithout <code>sessionData</code> so that the handshake can continue and a new session can\nbe created. It is possible to call <code>callback(err)</code> to terminate the incoming\nconnection and destroy the socket.</p>\n<p>Listening for this event will have an effect only on connections established\nafter the addition of the event listener.</p>\n<p>The following illustrates resuming a TLS session:</p>\n<pre><code class=\"language-js\">const tlsSessionStore = {};\nserver.on('newSession', (id, data, cb) => {\n  tlsSessionStore[id.toString('hex')] = data;\n  cb();\n});\nserver.on('resumeSession', (id, cb) => {\n  cb(null, tlsSessionStore[id.toString('hex')] || null);\n});\n</code></pre>"
            },
            {
              "textRaw": "Event: `'secureConnection'`",
              "name": "secureConnection",
              "type": "event",
              "meta": {
                "added": [
                  "v0.3.2"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`tlsSocket` {tls.TLSSocket} The established TLS socket.",
                  "name": "tlsSocket",
                  "type": "tls.TLSSocket",
                  "desc": "The established TLS socket."
                }
              ],
              "desc": "<p>The <code>'secureConnection'</code> event is emitted after the handshaking process for a\nnew connection has successfully completed. The listener callback is passed a\nsingle argument when called:</p>\n<p>The <code>tlsSocket.authorized</code> property is a <code>boolean</code> indicating whether the\nclient has been verified by one of the supplied Certificate Authorities for the\nserver. If <code>tlsSocket.authorized</code> is <code>false</code>, then <code>socket.authorizationError</code>\nis set to describe how authorization failed. Depending on the settings\nof the TLS server, unauthorized connections may still be accepted.</p>\n<p>The <code>tlsSocket.alpnProtocol</code> property is a string that contains the selected\nALPN protocol. When ALPN has no selected protocol because the client or the\nserver did not send an ALPN extension, <code>tlsSocket.alpnProtocol</code> equals <code>false</code>.</p>\n<p>The <code>tlsSocket.servername</code> property is a string containing the server name\nrequested via SNI.</p>"
            },
            {
              "textRaw": "Event: `'tlsClientError'`",
              "name": "tlsClientError",
              "type": "event",
              "meta": {
                "added": [
                  "v6.0.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`exception` {Error} The `Error` object describing the error",
                  "name": "exception",
                  "type": "Error",
                  "desc": "The `Error` object describing the error"
                },
                {
                  "textRaw": "`tlsSocket` {tls.TLSSocket} The `tls.TLSSocket` instance from which the error originated.",
                  "name": "tlsSocket",
                  "type": "tls.TLSSocket",
                  "desc": "The `tls.TLSSocket` instance from which the error originated."
                }
              ],
              "desc": "<p>The <code>'tlsClientError'</code> event is emitted when an error occurs before a secure\nconnection is established. The listener callback is passed two arguments when\ncalled:</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`server.addContext(hostname, context)`",
              "name": "addContext",
              "type": "method",
              "meta": {
                "added": [
                  "v0.5.3"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`hostname` {string} A SNI host name or wildcard (e.g. `'*'`)",
                      "name": "hostname",
                      "type": "string",
                      "desc": "A SNI host name or wildcard (e.g. `'*'`)"
                    },
                    {
                      "textRaw": "`context` {Object|tls.SecureContext} An object containing any of the possible properties from the `tls.createSecureContext()` `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created with `tls.createSecureContext()` itself.",
                      "name": "context",
                      "type": "Object|tls.SecureContext",
                      "desc": "An object containing any of the possible properties from the `tls.createSecureContext()` `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created with `tls.createSecureContext()` itself."
                    }
                  ]
                }
              ],
              "desc": "<p>The <code>server.addContext()</code> method adds a secure context that will be used if\nthe client request's SNI name matches the supplied <code>hostname</code> (or wildcard).</p>\n<p>When there are multiple matching contexts, the most recently added one is\nused.</p>"
            },
            {
              "textRaw": "`server.address()`",
              "name": "address",
              "type": "method",
              "meta": {
                "added": [
                  "v0.6.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object"
                  }
                }
              ],
              "desc": "<p>Returns the bound address, the address family name, and port of the\nserver as reported by the operating system. See <a href=\"net.html#serveraddress\"><code>net.Server.address()</code></a> for\nmore information.</p>"
            },
            {
              "textRaw": "`server.close([callback])`",
              "name": "close",
              "type": "method",
              "meta": {
                "added": [
                  "v0.3.2"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function} A listener callback that will be registered to listen for the server instance's `'close'` event.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "A listener callback that will be registered to listen for the server instance's `'close'` event.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {tls.Server}",
                    "name": "return",
                    "type": "tls.Server"
                  }
                }
              ],
              "desc": "<p>The <code>server.close()</code> method stops the server from accepting new connections.</p>\n<p>This function operates asynchronously. The <code>'close'</code> event will be emitted\nwhen the server has no more open connections.</p>"
            },
            {
              "textRaw": "`server.getTicketKeys()`",
              "name": "getTicketKeys",
              "type": "method",
              "meta": {
                "added": [
                  "v3.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Buffer} A 48-byte buffer containing the session ticket keys.",
                    "name": "return",
                    "type": "Buffer",
                    "desc": "A 48-byte buffer containing the session ticket keys."
                  }
                }
              ],
              "desc": "<p>Returns the session ticket keys.</p>\n<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>"
            },
            {
              "textRaw": "`server.listen()`",
              "name": "listen",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Starts the server listening for encrypted connections.\nThis method is identical to <a href=\"net.html#serverlisten\"><code>server.listen()</code></a> from <a href=\"net.html#class-netserver\"><code>net.Server</code></a>.</p>"
            },
            {
              "textRaw": "`server.setSecureContext(options)`",
              "name": "setSecureContext",
              "type": "method",
              "meta": {
                "added": [
                  "v11.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object} An object containing any of the possible properties from the `tls.createSecureContext()` `options` arguments (e.g. `key`, `cert`, `ca`, etc).",
                      "name": "options",
                      "type": "Object",
                      "desc": "An object containing any of the possible properties from the `tls.createSecureContext()` `options` arguments (e.g. `key`, `cert`, `ca`, etc)."
                    }
                  ]
                }
              ],
              "desc": "<p>The <code>server.setSecureContext()</code> method replaces the secure context of an\nexisting server. Existing connections to the server are not interrupted.</p>"
            },
            {
              "textRaw": "`server.setTicketKeys(keys)`",
              "name": "setTicketKeys",
              "type": "method",
              "meta": {
                "added": [
                  "v3.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`keys` {Buffer|TypedArray|DataView} A 48-byte buffer containing the session ticket keys.",
                      "name": "keys",
                      "type": "Buffer|TypedArray|DataView",
                      "desc": "A 48-byte buffer containing the session ticket keys."
                    }
                  ]
                }
              ],
              "desc": "<p>Sets the session ticket keys.</p>\n<p>Changes to the ticket keys are effective only for future server connections.\nExisting or currently pending server connections will use the previous keys.</p>\n<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `tls.TLSSocket`",
          "name": "tls.TLSSocket",
          "type": "class",
          "meta": {
            "added": [
              "v0.11.4"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"net.html#class-netsocket\"><code>&#x3C;net.Socket></code></a></li>\n</ul>\n<p>Performs transparent encryption of written data and all required TLS\nnegotiation.</p>\n<p>Instances of <code>tls.TLSSocket</code> implement the duplex <a href=\"stream.html#stream\">Stream</a> interface.</p>\n<p>Methods that return TLS connection metadata (e.g.\n<a href=\"#tlssocketgetpeercertificatedetailed\"><code>tls.TLSSocket.getPeerCertificate()</code></a>) will only return data while the\nconnection is open.</p>",
          "signatures": [
            {
              "textRaw": "`new tls.TLSSocket(socket[, options])`",
              "name": "tls.TLSSocket",
              "type": "ctor",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": [
                  {
                    "version": "v12.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/27497",
                    "description": "The `enableTrace` option is now supported."
                  },
                  {
                    "version": "v5.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/2564",
                    "description": "ALPN options are supported now."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`socket` {net.Socket|stream.Duplex} On the server side, any `Duplex` stream. On the client side, any instance of `net.Socket` (for generic `Duplex` stream support on the client side, `tls.connect()` must be used).",
                  "name": "socket",
                  "type": "net.Socket|stream.Duplex",
                  "desc": "On the server side, any `Duplex` stream. On the client side, any instance of `net.Socket` (for generic `Duplex` stream support on the client side, `tls.connect()` must be used)."
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`enableTrace`: See `tls.createServer()`",
                      "name": "enableTrace",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`isServer`: The SSL/TLS protocol is asymmetrical, TLSSockets must know if they are to behave as a server or a client. If `true` the TLS socket will be instantiated as a server. **Default:** `false`.",
                      "name": "isServer",
                      "default": "`false`",
                      "desc": "The SSL/TLS protocol is asymmetrical, TLSSockets must know if they are to behave as a server or a client. If `true` the TLS socket will be instantiated as a server."
                    },
                    {
                      "textRaw": "`server` {net.Server} A `net.Server` instance.",
                      "name": "server",
                      "type": "net.Server",
                      "desc": "A `net.Server` instance."
                    },
                    {
                      "textRaw": "`requestCert`: Whether to authenticate the remote peer by requesting a certificate. Clients always request a server certificate. Servers (`isServer` is true) may set `requestCert` to true to request a client certificate.",
                      "name": "requestCert",
                      "desc": "Whether to authenticate the remote peer by requesting a certificate. Clients always request a server certificate. Servers (`isServer` is true) may set `requestCert` to true to request a client certificate."
                    },
                    {
                      "textRaw": "`rejectUnauthorized`: See `tls.createServer()`",
                      "name": "rejectUnauthorized",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`ALPNProtocols`: See `tls.createServer()`",
                      "name": "ALPNProtocols",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`SNICallback`: See `tls.createServer()`",
                      "name": "SNICallback",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`ALPNCallback`: See `tls.createServer()`",
                      "name": "ALPNCallback",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`session` {Buffer} A `Buffer` instance containing a TLS session.",
                      "name": "session",
                      "type": "Buffer",
                      "desc": "A `Buffer` instance containing a TLS session."
                    },
                    {
                      "textRaw": "`requestOCSP` {boolean} If `true`, specifies that the OCSP status request extension will be added to the client hello and an `'OCSPResponse'` event will be emitted on the socket before establishing a secure communication",
                      "name": "requestOCSP",
                      "type": "boolean",
                      "desc": "If `true`, specifies that the OCSP status request extension will be added to the client hello and an `'OCSPResponse'` event will be emitted on the socket before establishing a secure communication"
                    },
                    {
                      "textRaw": "`secureContext`: TLS context object created with `tls.createSecureContext()`. If a `secureContext` is _not_ provided, one will be created by passing the entire `options` object to `tls.createSecureContext()`.",
                      "name": "secureContext",
                      "desc": "TLS context object created with `tls.createSecureContext()`. If a `secureContext` is _not_ provided, one will be created by passing the entire `options` object to `tls.createSecureContext()`."
                    },
                    {
                      "textRaw": "...: `tls.createSecureContext()` options that are used if the `secureContext` option is missing. Otherwise, they are ignored.",
                      "name": "..",
                      "desc": "`tls.createSecureContext()` options that are used if the `secureContext` option is missing. Otherwise, they are ignored."
                    }
                  ],
                  "optional": true
                }
              ],
              "desc": "<p>Construct a new <code>tls.TLSSocket</code> object from an existing TCP socket.</p>"
            }
          ],
          "events": [
            {
              "textRaw": "Event: `'keylog'`",
              "name": "keylog",
              "type": "event",
              "meta": {
                "added": [
                  "v12.3.0",
                  "v10.20.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`line` {Buffer} Line of ASCII text, in NSS `SSLKEYLOGFILE` format.",
                  "name": "line",
                  "type": "Buffer",
                  "desc": "Line of ASCII text, in NSS `SSLKEYLOGFILE` format."
                }
              ],
              "desc": "<p>The <code>keylog</code> event is emitted on a <code>tls.TLSSocket</code> when key material\nis generated or received by the socket. This keying material can be stored\nfor debugging, as it allows captured TLS traffic to be decrypted. It may\nbe emitted multiple times, before or after the handshake completes.</p>\n<p>A typical use case is to append received lines to a common text file, which\nis later used by software (such as Wireshark) to decrypt the traffic:</p>\n<pre><code class=\"language-js\">const logFile = fs.createWriteStream('/tmp/ssl-keys.log', { flags: 'a' });\n// ...\ntlsSocket.on('keylog', (line) => logFile.write(line));\n</code></pre>"
            },
            {
              "textRaw": "Event: `'OCSPResponse'`",
              "name": "OCSPResponse",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.13"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`response` {Buffer} The server's OCSP response",
                  "name": "response",
                  "type": "Buffer",
                  "desc": "The server's OCSP response"
                }
              ],
              "desc": "<p>The <code>'OCSPResponse'</code> event is emitted if the <code>requestOCSP</code> option was set\nwhen the <code>tls.TLSSocket</code> was created and an OCSP response has been received.\nThe listener callback is passed a single argument when called:</p>\n<p>Typically, the <code>response</code> is a digitally signed object from the server's CA that\ncontains information about server's certificate revocation status.</p>"
            },
            {
              "textRaw": "Event: `'secure'`",
              "name": "secure",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'secure'</code> event is emitted after the TLS handshake has successfully\ncompleted and a secure connection has been established.</p>\n<p>This event is emitted on both client and server <a href=\"tls.html#tlstlssocket\"><code>&#x3C;tls.TLSSocket></code></a> instances,\nincluding sockets created using the <code>new tls.TLSSocket()</code> constructor.</p>"
            },
            {
              "textRaw": "Event: `'secureConnect'`",
              "name": "secureConnect",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'secureConnect'</code> event is emitted after the handshaking process for a new\nconnection has successfully completed. The listener callback will be called\nregardless of whether or not the server's certificate has been authorized. It\nis the client's responsibility to check the <code>tlsSocket.authorized</code> property to\ndetermine if the server certificate was signed by one of the specified CAs. If\n<code>tlsSocket.authorized === false</code>, then the error can be found by examining the\n<code>tlsSocket.authorizationError</code> property. If ALPN was used, the\n<code>tlsSocket.alpnProtocol</code> property can be checked to determine the negotiated\nprotocol.</p>\n<p>The <code>'secureConnect'</code> event is not emitted when a <a href=\"tls.html#tlstlssocket\"><code>&#x3C;tls.TLSSocket></code></a> is created\nusing the <code>new tls.TLSSocket()</code> constructor.</p>"
            },
            {
              "textRaw": "Event: `'session'`",
              "name": "session",
              "type": "event",
              "meta": {
                "added": [
                  "v11.10.0"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`session` {Buffer}",
                  "name": "session",
                  "type": "Buffer"
                }
              ],
              "desc": "<p>The <code>'session'</code> event is emitted on a client <code>tls.TLSSocket</code> when a new session\nor TLS ticket is available. This may or may not be before the handshake is\ncomplete, depending on the TLS protocol version that was negotiated. The event\nis not emitted on the server, or if a new session was not created, for example,\nwhen the connection was resumed. For some TLS protocol versions the event may be\nemitted multiple times, in which case all the sessions can be used for\nresumption.</p>\n<p>On the client, the <code>session</code> can be provided to the <code>session</code> option of\n<a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a> to resume the connection.</p>\n<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>\n<p>For TLSv1.2 and below, <a href=\"#tlssocketgetsession\"><code>tls.TLSSocket.getSession()</code></a> can be called once\nthe handshake is complete. For TLSv1.3, only ticket-based resumption is allowed\nby the protocol, multiple tickets are sent, and the tickets aren't sent until\nafter the handshake completes. So it is necessary to wait for the\n<code>'session'</code> event to get a resumable session. Applications\nshould use the <code>'session'</code> event instead of <code>getSession()</code> to ensure\nthey will work for all TLS versions. Applications that only expect to\nget or use one session should listen for this event only once:</p>\n<pre><code class=\"language-js\">tlsSocket.once('session', (session) => {\n  // The session can be used immediately or later.\n  tls.connect({\n    session: session,\n    // Other connect options...\n  });\n});\n</code></pre>"
            }
          ],
          "methods": [
            {
              "textRaw": "`tlsSocket.address()`",
              "name": "address",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": [
                  {
                    "version": "v18.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/43054",
                    "description": "The `family` property now returns a string instead of a number."
                  },
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41431",
                    "description": "The `family` property now returns a number instead of a string."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object"
                  }
                }
              ],
              "desc": "<p>Returns the bound <code>address</code>, the address <code>family</code> name, and <code>port</code> of the\nunderlying socket as reported by the operating system:\n<code>{ port: 12346, family: 'IPv4', address: '127.0.0.1' }</code>.</p>"
            },
            {
              "textRaw": "`tlsSocket.disableRenegotiation()`",
              "name": "disableRenegotiation",
              "type": "method",
              "meta": {
                "added": [
                  "v8.4.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Disables TLS renegotiation for this <code>TLSSocket</code> instance. Once called, attempts\nto renegotiate will trigger an <code>'error'</code> event on the <code>TLSSocket</code>.</p>"
            },
            {
              "textRaw": "`tlsSocket.enableTrace()`",
              "name": "enableTrace",
              "type": "method",
              "meta": {
                "added": [
                  "v12.2.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>When enabled, TLS packet trace information is written to <code>stderr</code>. This can be\nused to debug TLS connection problems.</p>\n<p>The format of the output is identical to the output of\n<code>openssl s_client -trace</code> or <code>openssl s_server -trace</code>. While it is produced by\nOpenSSL's <code>SSL_trace()</code> function, the format is undocumented, can change\nwithout notice, and should not be relied on.</p>"
            },
            {
              "textRaw": "`tlsSocket.exportKeyingMaterial(length, label[, context])`",
              "name": "exportKeyingMaterial",
              "type": "method",
              "meta": {
                "added": [
                  "v13.10.0",
                  "v12.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`length` {number} number of bytes to retrieve from keying material",
                      "name": "length",
                      "type": "number",
                      "desc": "number of bytes to retrieve from keying material"
                    },
                    {
                      "textRaw": "`label` {string} an application specific label, typically this will be a value from the IANA Exporter Label Registry.",
                      "name": "label",
                      "type": "string",
                      "desc": "an application specific label, typically this will be a value from the IANA Exporter Label Registry."
                    },
                    {
                      "textRaw": "`context` {Buffer} Optionally provide a context.",
                      "name": "context",
                      "type": "Buffer",
                      "desc": "Optionally provide a context.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Buffer} requested bytes of the keying material",
                    "name": "return",
                    "type": "Buffer",
                    "desc": "requested bytes of the keying material"
                  }
                }
              ],
              "desc": "<p>Keying material is used for validations to prevent different kind of attacks in\nnetwork protocols, for example in the specifications of IEEE 802.1X.</p>\n<p>Example</p>\n<pre><code class=\"language-js\">const keyingMaterial = tlsSocket.exportKeyingMaterial(\n  128,\n  'client finished');\n\n/*\n Example return value of keyingMaterial:\n &#x3C;Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9\n    12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91\n    74 ef 2c ... 78 more bytes>\n*/\n</code></pre>\n<p>See the OpenSSL <a href=\"https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html\"><code>SSL_export_keying_material</code></a> documentation for more\ninformation.</p>"
            },
            {
              "textRaw": "`tlsSocket.getCertificate()`",
              "name": "getCertificate",
              "type": "method",
              "meta": {
                "added": [
                  "v11.2.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object"
                  }
                }
              ],
              "desc": "<p>Returns an object representing the local certificate. The returned object has\nsome properties corresponding to the fields of the certificate.</p>\n<p>See <a href=\"#tlssocketgetpeercertificatedetailed\"><code>tls.TLSSocket.getPeerCertificate()</code></a> for an example of the certificate\nstructure.</p>\n<p>If there is no local certificate, an empty object will be returned. If the\nsocket has been destroyed, <code>null</code> will be returned.</p>"
            },
            {
              "textRaw": "`tlsSocket.getCipher()`",
              "name": "getCipher",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": [
                  {
                    "version": [
                      "v13.4.0",
                      "v12.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/30637",
                    "description": "Return the IETF cipher name as `standardName`."
                  },
                  {
                    "version": "v12.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/26625",
                    "description": "Return the minimum cipher version, instead of a fixed string (`'TLSv1/SSLv3'`)."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object",
                    "options": [
                      {
                        "textRaw": "`name` {string} OpenSSL name for the cipher suite.",
                        "name": "name",
                        "type": "string",
                        "desc": "OpenSSL name for the cipher suite."
                      },
                      {
                        "textRaw": "`standardName` {string} IETF name for the cipher suite.",
                        "name": "standardName",
                        "type": "string",
                        "desc": "IETF name for the cipher suite."
                      },
                      {
                        "textRaw": "`version` {string} The minimum TLS protocol version supported by this cipher suite. For the actual negotiated protocol, see `tls.TLSSocket.getProtocol()`.",
                        "name": "version",
                        "type": "string",
                        "desc": "The minimum TLS protocol version supported by this cipher suite. For the actual negotiated protocol, see `tls.TLSSocket.getProtocol()`."
                      }
                    ]
                  }
                }
              ],
              "desc": "<p>Returns an object containing information on the negotiated cipher suite.</p>\n<p>For example, a TLSv1.2 protocol with AES256-SHA cipher:</p>\n<pre><code class=\"language-json\">{\n    \"name\": \"AES256-SHA\",\n    \"standardName\": \"TLS_RSA_WITH_AES_256_CBC_SHA\",\n    \"version\": \"SSLv3\"\n}\n</code></pre>\n<p>See\n<a href=\"https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html\">SSL_CIPHER_get_name</a>\nfor more information.</p>"
            },
            {
              "textRaw": "`tlsSocket.getEphemeralKeyInfo()`",
              "name": "getEphemeralKeyInfo",
              "type": "method",
              "meta": {
                "added": [
                  "v5.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object"
                  }
                }
              ],
              "desc": "<p>Returns an object representing the type, name, and size of parameter of\nan ephemeral key exchange in <a href=\"#perfect-forward-secrecy\">perfect forward secrecy</a> on a client\nconnection. It returns an empty object when the key exchange is not\nephemeral. As this is only supported on a client socket; <code>null</code> is returned\nif called on a server socket. The supported types are <code>'DH'</code> and <code>'ECDH'</code>. The\n<code>name</code> property is available only when type is <code>'ECDH'</code>.</p>\n<p>For example: <code>{ type: 'ECDH', name: 'prime256v1', size: 256 }</code>.</p>"
            },
            {
              "textRaw": "`tlsSocket.getFinished()`",
              "name": "getFinished",
              "type": "method",
              "meta": {
                "added": [
                  "v9.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Buffer|undefined} The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet.",
                    "name": "return",
                    "type": "Buffer|undefined",
                    "desc": "The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet."
                  }
                }
              ],
              "desc": "<p>As the <code>Finished</code> messages are message digests of the complete handshake\n(with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can\nbe used for external authentication procedures when the authentication\nprovided by SSL/TLS is not desired or is not enough.</p>\n<p>Corresponds to the <code>SSL_get_finished</code> routine in OpenSSL and may be used\nto implement the <code>tls-unique</code> channel binding from <a href=\"https://tools.ietf.org/html/rfc5929\">RFC 5929</a>.</p>"
            },
            {
              "textRaw": "`tlsSocket.getPeerCertificate([detailed])`",
              "name": "getPeerCertificate",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`detailed` {boolean} Include the full certificate chain if `true`, otherwise include just the peer's certificate.",
                      "name": "detailed",
                      "type": "boolean",
                      "desc": "Include the full certificate chain if `true`, otherwise include just the peer's certificate.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Object} A certificate object.",
                    "name": "return",
                    "type": "Object",
                    "desc": "A certificate object."
                  }
                }
              ],
              "desc": "<p>Returns an object representing the peer's certificate. If the peer does not\nprovide a certificate, an empty object will be returned. If the socket has been\ndestroyed, <code>null</code> will be returned.</p>\n<p>If the full certificate chain was requested, each certificate will include an\n<code>issuerCertificate</code> property containing an object representing its issuer's\ncertificate.</p>",
              "modules": [
                {
                  "textRaw": "Certificate object",
                  "name": "certificate_object",
                  "type": "module",
                  "meta": {
                    "changes": [
                      {
                        "version": [
                          "v19.1.0",
                          "v18.13.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/44935",
                        "description": "Add \"ca\" property."
                      },
                      {
                        "version": [
                          "v17.2.0",
                          "v16.14.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/39809",
                        "description": "Add fingerprint512."
                      },
                      {
                        "version": "v11.4.0",
                        "pr-url": "https://github.com/nodejs/node/pull/24358",
                        "description": "Support Elliptic Curve public key info."
                      }
                    ]
                  },
                  "desc": "<p>A certificate object has properties corresponding to the fields of the\ncertificate.</p>\n<ul>\n<li><code>ca</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type\"><code>&#x3C;boolean></code></a> <code>true</code> if a Certificate Authority (CA), <code>false</code> otherwise.</li>\n<li><code>raw</code> <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a> The DER encoded X.509 certificate data.</li>\n<li><code>subject</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> The certificate subject, described in terms of\nCountry (<code>C</code>), StateOrProvince (<code>ST</code>), Locality (<code>L</code>), Organization (<code>O</code>),\nOrganizationalUnit (<code>OU</code>), and CommonName (<code>CN</code>). The CommonName is typically\na DNS name with TLS certificates. Example:\n<code>{C: 'UK', ST: 'BC', L: 'Metro', O: 'Node Fans', OU: 'Docs', CN: 'example.com'}</code>.</li>\n<li><code>issuer</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> The certificate issuer, described in the same terms as the <code>subject</code>.</li>\n<li><code>valid_from</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The date-time the certificate is valid from.</li>\n<li><code>valid_to</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The date-time the certificate is valid to.</li>\n<li><code>serialNumber</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The certificate serial number, as a hex string.\nExample: <code>'B9B0D332A1AA5635'</code>.</li>\n<li><code>fingerprint</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The SHA-1 digest of the DER encoded certificate. It is\nreturned as a <code>:</code> separated hexadecimal string. Example: <code>'2A:7A:C2:DD:...'</code>.</li>\n<li><code>fingerprint256</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The SHA-256 digest of the DER encoded certificate.\nIt is returned as a <code>:</code> separated hexadecimal string. Example:\n<code>'2A:7A:C2:DD:...'</code>.</li>\n<li><code>fingerprint512</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The SHA-512 digest of the DER encoded certificate.\nIt is returned as a <code>:</code> separated hexadecimal string. Example:\n<code>'2A:7A:C2:DD:...'</code>.</li>\n<li><code>ext_key_usage</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\"><code>&#x3C;Array></code></a> (Optional) The extended key usage, a set of OIDs.</li>\n<li><code>subjectaltname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> (Optional) A string containing concatenated names\nfor the subject, an alternative to the <code>subject</code> names.</li>\n<li><code>infoAccess</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\"><code>&#x3C;Array></code></a> (Optional) An array describing the AuthorityInfoAccess,\nused with OCSP.</li>\n<li><code>issuerCertificate</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> (Optional) The issuer certificate object. For\nself-signed certificates, this may be a circular reference.</li>\n</ul>\n<p>The certificate may contain information about the public key, depending on\nthe key type.</p>\n<p>For RSA keys, the following properties may be defined:</p>\n<ul>\n<li><code>bits</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> The RSA bit size. Example: <code>1024</code>.</li>\n<li><code>exponent</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The RSA exponent, as a string in hexadecimal number\nnotation. Example: <code>'0x010001'</code>.</li>\n<li><code>modulus</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The RSA modulus, as a hexadecimal string. Example: <code>'B56CE45CB7...'</code>.</li>\n<li><code>pubkey</code> <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a> The public key.</li>\n</ul>\n<p>For EC keys, the following properties may be defined:</p>\n<ul>\n<li><code>pubkey</code> <a href=\"buffer.html#class-buffer\"><code>&#x3C;Buffer></code></a> The public key.</li>\n<li><code>bits</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a> The key size in bits. Example: <code>256</code>.</li>\n<li><code>asn1Curve</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> (Optional) The ASN.1 name of the OID of the elliptic\ncurve. Well-known curves are identified by an OID. While it is unusual, it is\npossible that the curve is identified by its mathematical properties, in which\ncase it will not have an OID. Example: <code>'prime256v1'</code>.</li>\n<li><code>nistCurve</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> (Optional) The NIST name for the elliptic curve, if it\nhas one (not all well-known curves have been assigned names by NIST). Example: <code>'P-256'</code>.</li>\n</ul>\n<p>Example certificate:</p>\n<pre><code class=\"language-js\">{ subject:\n   { OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],\n     CN: '*.nodejs.org' },\n  issuer:\n   { C: 'GB',\n     ST: 'Greater Manchester',\n     L: 'Salford',\n     O: 'COMODO CA Limited',\n     CN: 'COMODO RSA Domain Validation Secure Server CA' },\n  subjectaltname: 'DNS:*.nodejs.org, DNS:nodejs.org',\n  infoAccess:\n   { 'CA Issuers - URI':\n      [ 'http://crt.comodoca.com/COMODORSADomainValidationSecureServerCA.crt' ],\n     'OCSP - URI': [ 'http://ocsp.comodoca.com' ] },\n  modulus: 'B56CE45CB740B09A13F64AC543B712FF9EE8E4C284B542A1708A27E82A8D151CA178153E12E6DDA15BF70FFD96CB8A88618641BDFCCA03527E665B70D779C8A349A6F88FD4EF6557180BD4C98192872BCFE3AF56E863C09DDD8BC1EC58DF9D94F914F0369102B2870BECFA1348A0838C9C49BD1C20124B442477572347047506B1FCD658A80D0C44BCC16BC5C5496CFE6E4A8428EF654CD3D8972BF6E5BFAD59C93006830B5EB1056BBB38B53D1464FA6E02BFDF2FF66CD949486F0775EC43034EC2602AEFBF1703AD221DAA2A88353C3B6A688EFE8387811F645CEED7B3FE46E1F8B9F59FAD028F349B9BC14211D5830994D055EEA3D547911E07A0ADDEB8A82B9188E58720D95CD478EEC9AF1F17BE8141BE80906F1A339445A7EB5B285F68039B0F294598A7D1C0005FC22B5271B0752F58CCDEF8C8FD856FB7AE21C80B8A2CE983AE94046E53EDE4CB89F42502D31B5360771C01C80155918637490550E3F555E2EE75CC8C636DDE3633CFEDD62E91BF0F7688273694EEEBA20C2FC9F14A2A435517BC1D7373922463409AB603295CEB0BB53787A334C9CA3CA8B30005C5A62FC0715083462E00719A8FA3ED0A9828C3871360A73F8B04A4FC1E71302844E9BB9940B77E745C9D91F226D71AFCAD4B113AAF68D92B24DDB4A2136B55A1CD1ADF39605B63CB639038ED0F4C987689866743A68769CC55847E4A06D6E2E3F1',\n  exponent: '0x10001',\n  pubkey: &#x3C;Buffer ... >,\n  valid_from: 'Aug 14 00:00:00 2017 GMT',\n  valid_to: 'Nov 20 23:59:59 2019 GMT',\n  fingerprint: '01:02:59:D9:C3:D2:0D:08:F7:82:4E:44:A4:B4:53:C5:E2:3A:87:4D',\n  fingerprint256: '69:AE:1A:6A:D4:3D:C6:C1:1B:EA:C6:23:DE:BA:2A:14:62:62:93:5C:7A:EA:06:41:9B:0B:BC:87:CE:48:4E:02',\n  fingerprint512: '19:2B:3E:C3:B3:5B:32:E8:AE:BB:78:97:27:E4:BA:6C:39:C9:92:79:4F:31:46:39:E2:70:E5:5F:89:42:17:C9:E8:64:CA:FF:BB:72:56:73:6E:28:8A:92:7E:A3:2A:15:8B:C2:E0:45:CA:C3:BC:EA:40:52:EC:CA:A2:68:CB:32',\n  ext_key_usage: [ '1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2' ],\n  serialNumber: '66593D57F20CBC573E433381B5FEC280',\n  raw: &#x3C;Buffer ... > }\n</code></pre>",
                  "displayName": "Certificate object"
                }
              ]
            },
            {
              "textRaw": "`tlsSocket.getPeerFinished()`",
              "name": "getPeerFinished",
              "type": "method",
              "meta": {
                "added": [
                  "v9.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Buffer|undefined} The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so far.",
                    "name": "return",
                    "type": "Buffer|undefined",
                    "desc": "The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so far."
                  }
                }
              ],
              "desc": "<p>As the <code>Finished</code> messages are message digests of the complete handshake\n(with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can\nbe used for external authentication procedures when the authentication\nprovided by SSL/TLS is not desired or is not enough.</p>\n<p>Corresponds to the <code>SSL_get_peer_finished</code> routine in OpenSSL and may be used\nto implement the <code>tls-unique</code> channel binding from <a href=\"https://tools.ietf.org/html/rfc5929\">RFC 5929</a>.</p>"
            },
            {
              "textRaw": "`tlsSocket.getPeerX509Certificate()`",
              "name": "getPeerX509Certificate",
              "type": "method",
              "meta": {
                "added": [
                  "v15.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {X509Certificate}",
                    "name": "return",
                    "type": "X509Certificate"
                  }
                }
              ],
              "desc": "<p>Returns the peer certificate as an <a href=\"crypto.html#class-x509certificate\"><code>&#x3C;X509Certificate></code></a> object.</p>\n<p>If there is no peer certificate, or the socket has been destroyed,\n<code>undefined</code> will be returned.</p>"
            },
            {
              "textRaw": "`tlsSocket.getProtocol()`",
              "name": "getProtocol",
              "type": "method",
              "meta": {
                "added": [
                  "v5.7.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {string|null}",
                    "name": "return",
                    "type": "string|null"
                  }
                }
              ],
              "desc": "<p>Returns a string containing the negotiated SSL/TLS protocol version of the\ncurrent connection. The value <code>'unknown'</code> will be returned for connected\nsockets that have not completed the handshaking process. The value <code>null</code> will\nbe returned for server sockets or disconnected client sockets.</p>\n<p>Protocol versions are:</p>\n<ul>\n<li><code>'SSLv3'</code></li>\n<li><code>'TLSv1'</code></li>\n<li><code>'TLSv1.1'</code></li>\n<li><code>'TLSv1.2'</code></li>\n<li><code>'TLSv1.3'</code></li>\n</ul>\n<p>See the OpenSSL <a href=\"https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html\"><code>SSL_get_version</code></a> documentation for more information.</p>"
            },
            {
              "textRaw": "`tlsSocket.getSession()`",
              "name": "getSession",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Returns the TLS session data or <code>undefined</code> if no session was\nnegotiated. On the client, the data can be provided to the <code>session</code> option of\n<a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a> to resume the connection. On the server, it may be useful\nfor debugging.</p>\n<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>\n<p>Note: <code>getSession()</code> works only for TLSv1.2 and below. For TLSv1.3, applications\nmust use the <a href=\"#event-session\"><code>'session'</code></a> event (it also works for TLSv1.2 and below).</p>"
            },
            {
              "textRaw": "`tlsSocket.getSharedSigalgs()`",
              "name": "getSharedSigalgs",
              "type": "method",
              "meta": {
                "added": [
                  "v12.11.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Array} List of signature algorithms shared between the server and the client in the order of decreasing preference.",
                    "name": "return",
                    "type": "Array",
                    "desc": "List of signature algorithms shared between the server and the client in the order of decreasing preference."
                  }
                }
              ],
              "desc": "<p>See\n<a href=\"https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html\">SSL_get_shared_sigalgs</a>\nfor more information.</p>"
            },
            {
              "textRaw": "`tlsSocket.getTLSTicket()`",
              "name": "getTLSTicket",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>For a client, returns the TLS session ticket if one is available, or\n<code>undefined</code>. For a server, always returns <code>undefined</code>.</p>\n<p>It may be useful for debugging.</p>\n<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>"
            },
            {
              "textRaw": "`tlsSocket.getX509Certificate()`",
              "name": "getX509Certificate",
              "type": "method",
              "meta": {
                "added": [
                  "v15.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {X509Certificate}",
                    "name": "return",
                    "type": "X509Certificate"
                  }
                }
              ],
              "desc": "<p>Returns the local certificate as an <a href=\"crypto.html#class-x509certificate\"><code>&#x3C;X509Certificate></code></a> object.</p>\n<p>If there is no local certificate, or the socket has been destroyed,\n<code>undefined</code> will be returned.</p>"
            },
            {
              "textRaw": "`tlsSocket.isSessionReused()`",
              "name": "isSessionReused",
              "type": "method",
              "meta": {
                "added": [
                  "v0.5.6"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {boolean} `true` if the session was reused, `false` otherwise.",
                    "name": "return",
                    "type": "boolean",
                    "desc": "`true` if the session was reused, `false` otherwise."
                  }
                }
              ],
              "desc": "<p>See <a href=\"#session-resumption\">Session Resumption</a> for more information.</p>"
            },
            {
              "textRaw": "`tlsSocket.renegotiate(options, callback)`",
              "name": "renegotiate",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.8"
                ],
                "changes": [
                  {
                    "version": "v18.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/41678",
                    "description": "Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`rejectUnauthorized` {boolean} If not `false`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code. **Default:** `true`.",
                          "name": "rejectUnauthorized",
                          "type": "boolean",
                          "default": "`true`",
                          "desc": "If not `false`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code."
                        },
                        {
                          "textRaw": "`requestCert`",
                          "name": "requestCert"
                        }
                      ]
                    },
                    {
                      "textRaw": "`callback` {Function} If `renegotiate()` returned `true`, callback is attached once to the `'secure'` event. If `renegotiate()` returned `false`, `callback` will be called in the next tick with an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "If `renegotiate()` returned `true`, callback is attached once to the `'secure'` event. If `renegotiate()` returned `false`, `callback` will be called in the next tick with an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean} `true` if renegotiation was initiated, `false` otherwise.",
                    "name": "return",
                    "type": "boolean",
                    "desc": "`true` if renegotiation was initiated, `false` otherwise."
                  }
                }
              ],
              "desc": "<p>The <code>tlsSocket.renegotiate()</code> method initiates a TLS renegotiation process.\nUpon completion, the <code>callback</code> function will be passed a single argument\nthat is either an <code>Error</code> (if the request failed) or <code>null</code>.</p>\n<p>This method can be used to request a peer's certificate after the secure\nconnection has been established.</p>\n<p>When running as the server, the socket will be destroyed with an error after\n<code>handshakeTimeout</code> timeout.</p>\n<p>For TLSv1.3, renegotiation cannot be initiated, it is not supported by the\nprotocol.</p>"
            },
            {
              "textRaw": "`tlsSocket.setKeyCert(context)`",
              "name": "setKeyCert",
              "type": "method",
              "meta": {
                "added": [
                  "v22.5.0",
                  "v20.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`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.",
                      "name": "context",
                      "type": "Object|tls.SecureContext",
                      "desc": "An object containing at least `key` and `cert` properties from the `tls.createSecureContext()` `options`, or a TLS context object created with `tls.createSecureContext()` itself."
                    }
                  ]
                }
              ],
              "desc": "<p>The <code>tlsSocket.setKeyCert()</code> method sets the private key and certificate to use\nfor the socket. This is mainly useful if you wish to select a server certificate\nfrom a TLS server's <code>ALPNCallback</code>.</p>"
            },
            {
              "textRaw": "`tlsSocket.setMaxSendFragment(size)`",
              "name": "setMaxSendFragment",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.11"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`size` {number} The maximum TLS fragment size. The maximum value is `16384`. **Default:** `16384`.",
                      "name": "size",
                      "type": "number",
                      "default": "`16384`",
                      "desc": "The maximum TLS fragment size. The maximum value is `16384`."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>The <code>tlsSocket.setMaxSendFragment()</code> method sets the maximum TLS fragment size.\nReturns <code>true</code> if setting the limit succeeded; <code>false</code> otherwise.</p>\n<p>Smaller fragment sizes decrease the buffering latency on the client: larger\nfragments are buffered by the TLS layer until the entire fragment is received\nand its integrity is verified; large fragments can span multiple roundtrips\nand their processing can be delayed due to packet loss or reordering. However,\nsmaller fragments add extra TLS framing bytes and CPU overhead, which may\ndecrease overall server throughput.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "`tlsSocket.authorizationError`",
              "name": "authorizationError",
              "type": "property",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the reason why the peer's certificate was not been verified. This\nproperty is set only when <code>tlsSocket.authorized === false</code>.</p>"
            },
            {
              "textRaw": "Type: {boolean}",
              "name": "authorized",
              "type": "boolean",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>This property is <code>true</code> if the peer certificate was signed by one of the CAs\nspecified when creating the <code>tls.TLSSocket</code> instance, otherwise <code>false</code>.</p>"
            },
            {
              "textRaw": "`tlsSocket.encrypted`",
              "name": "encrypted",
              "type": "property",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Always returns <code>true</code>. This may be used to distinguish TLS sockets from regular\n<code>net.Socket</code> instances.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "localAddress",
              "type": "string",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the string representation of the local IP address.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "localPort",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the numeric representation of the local port.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "remoteAddress",
              "type": "string",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the string representation of the remote IP address. For example,\n<code>'74.125.127.100'</code> or <code>'2001:4860:a005::68'</code>.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "remoteFamily",
              "type": "string",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the string representation of the remote IP family. <code>'IPv4'</code> or <code>'IPv6'</code>.</p>"
            },
            {
              "textRaw": "Type: {integer}",
              "name": "remotePort",
              "type": "integer",
              "meta": {
                "added": [
                  "v0.11.4"
                ],
                "changes": []
              },
              "desc": "<p>Returns the numeric representation of the remote port. For example, <code>443</code>.</p>"
            }
          ]
        }
      ],
      "methods": [
        {
          "textRaw": "`tls.checkServerIdentity(hostname, cert)`",
          "name": "checkServerIdentity",
          "type": "method",
          "meta": {
            "added": [
              "v0.8.4"
            ],
            "changes": [
              {
                "version": [
                  "v17.3.1",
                  "v16.13.2",
                  "v14.18.3",
                  "v12.22.9"
                ],
                "pr-url": "https://github.com/nodejs-private/node-private/pull/300",
                "description": "Support for `uniformResourceIdentifier` subject alternative names has been disabled in response to CVE-2021-44531."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`hostname` {string} The host name or IP address to verify the certificate against.",
                  "name": "hostname",
                  "type": "string",
                  "desc": "The host name or IP address to verify the certificate against."
                },
                {
                  "textRaw": "`cert` {Object} A certificate object representing the peer's certificate.",
                  "name": "cert",
                  "type": "Object",
                  "desc": "A certificate object representing the peer's certificate."
                }
              ],
              "return": {
                "textRaw": "Returns: {Error|undefined}",
                "name": "return",
                "type": "Error|undefined"
              }
            }
          ],
          "desc": "<p>Verifies the certificate <code>cert</code> is issued to <code>hostname</code>.</p>\n<p>Returns <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\"><code>&#x3C;Error></code></a> object, populating it with <code>reason</code>, <code>host</code>, and <code>cert</code> on\nfailure. On success, returns <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type\"><code>&#x3C;undefined></code></a>.</p>\n<p>This function is intended to be used in combination with the\n<code>checkServerIdentity</code> option that can be passed to <a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a> and as\nsuch operates on a <a href=\"#certificate-object\">certificate object</a>. For other purposes, consider using\n<a href=\"crypto.html#x509checkhostname-options\"><code>x509.checkHost()</code></a> instead.</p>\n<p>This function can be overwritten by providing an alternative function as the\n<code>options.checkServerIdentity</code> option that is passed to <code>tls.connect()</code>. The\noverwriting function can call <code>tls.checkServerIdentity()</code> of course, to augment\nthe checks done with additional verification.</p>\n<p>This function is only called if the certificate passed all other checks, such as\nbeing issued by trusted CA (<code>options.ca</code>).</p>\n<p>Earlier versions of Node.js incorrectly accepted certificates for a given\n<code>hostname</code> if a matching <code>uniformResourceIdentifier</code> subject alternative name\nwas present (see <a href=\"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531\">CVE-2021-44531</a>). Applications that wish to accept\n<code>uniformResourceIdentifier</code> subject alternative names can use a custom\n<code>options.checkServerIdentity</code> function that implements the desired behavior.</p>"
        },
        {
          "textRaw": "`tls.connect(options[, callback])`",
          "name": "connect",
          "type": "method",
          "meta": {
            "added": [
              "v0.11.3"
            ],
            "changes": [
              {
                "version": [
                  "v15.1.0",
                  "v14.18.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/35753",
                "description": "Added `onread` option."
              },
              {
                "version": [
                  "v14.1.0",
                  "v13.14.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/32786",
                "description": "The `highWaterMark` option is accepted now."
              },
              {
                "version": [
                  "v13.6.0",
                  "v12.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/23188",
                "description": "The `pskCallback` option is now supported."
              },
              {
                "version": "v12.9.0",
                "pr-url": "https://github.com/nodejs/node/pull/27836",
                "description": "Support the `allowHalfOpen` option."
              },
              {
                "version": "v12.4.0",
                "pr-url": "https://github.com/nodejs/node/pull/27816",
                "description": "The `hints` option is now supported."
              },
              {
                "version": "v12.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/27497",
                "description": "The `enableTrace` option is now supported."
              },
              {
                "version": [
                  "v11.8.0",
                  "v10.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/25517",
                "description": "The `timeout` option is supported now."
              },
              {
                "version": "v8.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/12839",
                "description": "The `lookup` option is supported now."
              },
              {
                "version": "v8.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/11984",
                "description": "The `ALPNProtocols` option can be a `TypedArray` or `DataView` now."
              },
              {
                "version": [
                  "v5.3.0",
                  "v4.7.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/4246",
                "description": "The `secureContext` option is supported now."
              },
              {
                "version": "v5.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/2564",
                "description": "ALPN options are supported now."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`enableTrace`: See `tls.createServer()`",
                      "name": "enableTrace",
                      "desc": "See `tls.createServer()`"
                    },
                    {
                      "textRaw": "`host` {string} Host the client should connect to. **Default:** `'localhost'`.",
                      "name": "host",
                      "type": "string",
                      "default": "`'localhost'`",
                      "desc": "Host the client should connect to."
                    },
                    {
                      "textRaw": "`port` {number} Port the client should connect to.",
                      "name": "port",
                      "type": "number",
                      "desc": "Port the client should connect to."
                    },
                    {
                      "textRaw": "`path` {string} Creates Unix socket connection to path. If this option is specified, `host` and `port` are ignored.",
                      "name": "path",
                      "type": "string",
                      "desc": "Creates Unix socket connection to path. If this option is specified, `host` and `port` are ignored."
                    },
                    {
                      "textRaw": "`socket` {stream.Duplex} Establish secure connection on a given socket rather than creating a new socket. Typically, this is an instance of `net.Socket`, but any `Duplex` stream is allowed. If this option is specified, `path`, `host`, and `port` are ignored, except for certificate validation. Usually, a socket is already connected when passed to `tls.connect()`, but it can be connected later. Connection/disconnection/destruction of `socket` is the user's responsibility; calling `tls.connect()` will not cause `net.connect()` to be called.",
                      "name": "socket",
                      "type": "stream.Duplex",
                      "desc": "Establish secure connection on a given socket rather than creating a new socket. Typically, this is an instance of `net.Socket`, but any `Duplex` stream is allowed. If this option is specified, `path`, `host`, and `port` are ignored, except for certificate validation. Usually, a socket is already connected when passed to `tls.connect()`, but it can be connected later. Connection/disconnection/destruction of `socket` is the user's responsibility; calling `tls.connect()` will not cause `net.connect()` to be called."
                    },
                    {
                      "textRaw": "`allowHalfOpen` {boolean} If set to `false`, then the socket will automatically end the writable side when the readable side ends. If the `socket` option is set, this option has no effect. See the `allowHalfOpen` option of `net.Socket` for details. **Default:** `false`.",
                      "name": "allowHalfOpen",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If set to `false`, then the socket will automatically end the writable side when the readable side ends. If the `socket` option is set, this option has no effect. See the `allowHalfOpen` option of `net.Socket` for details."
                    },
                    {
                      "textRaw": "`rejectUnauthorized` {boolean} If not `false`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code. **Default:** `true`.",
                      "name": "rejectUnauthorized",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "If not `false`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code."
                    },
                    {
                      "textRaw": "`pskCallback` {Function} For TLS-PSK negotiation, see Pre-shared keys.",
                      "name": "pskCallback",
                      "type": "Function",
                      "desc": "For TLS-PSK negotiation, see Pre-shared keys."
                    },
                    {
                      "textRaw": "`ALPNProtocols` {string[]|Buffer|TypedArray|DataView} An array of strings, or a single `Buffer`, `TypedArray`, or `DataView` containing the supported ALPN protocols. Buffers should have the format `[len][name][len][name]...` e.g. `'\\x08http/1.1\\x08http/1.0'`, where the `len` byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['http/1.1', 'http/1.0']`. Protocols earlier in the list have higher preference than those later.",
                      "name": "ALPNProtocols",
                      "type": "string[]|Buffer|TypedArray|DataView",
                      "desc": "An array of strings, or a single `Buffer`, `TypedArray`, or `DataView` containing the supported ALPN protocols. Buffers should have the format `[len][name][len][name]...` e.g. `'\\x08http/1.1\\x08http/1.0'`, where the `len` byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['http/1.1', 'http/1.0']`. Protocols earlier in the list have higher preference than those later."
                    },
                    {
                      "textRaw": "`servername` {string} Server name for the SNI (Server Name Indication) TLS extension. It is the name of the host being connected to, and must be a host name, and not an IP address. It can be used by a multi-homed server to choose the correct certificate to present to the client, see the `SNICallback` option to `tls.createServer()`.",
                      "name": "servername",
                      "type": "string",
                      "desc": "Server name for the SNI (Server Name Indication) TLS extension. It is the name of the host being connected to, and must be a host name, and not an IP address. It can be used by a multi-homed server to choose the correct certificate to present to the client, see the `SNICallback` option to `tls.createServer()`."
                    },
                    {
                      "textRaw": "`checkServerIdentity(servername, cert)` {Function} A callback function to be used (instead of the builtin `tls.checkServerIdentity()` function) when checking the server's host name (or the provided `servername` when explicitly set) against the certificate. This should return an {Error} if verification fails. The method should return `undefined` if the `servername` and `cert` are verified.",
                      "name": "checkServerIdentity(servername,",
                      "desc": "cert)` {Function} A callback function to be used (instead of the builtin `tls.checkServerIdentity()` function) when checking the server's host name (or the provided `servername` when explicitly set) against the certificate. This should return an {Error} if verification fails. The method should return `undefined` if the `servername` and `cert` are verified."
                    },
                    {
                      "textRaw": "`session` {Buffer} A `Buffer` instance, containing TLS session.",
                      "name": "session",
                      "type": "Buffer",
                      "desc": "A `Buffer` instance, containing TLS session."
                    },
                    {
                      "textRaw": "`requestOCSP` {boolean} If `true`, specifies that the OCSP status request extension will be added to the client hello and an `'OCSPResponse'` event will be emitted on the socket before establishing a secure communication.",
                      "name": "requestOCSP",
                      "type": "boolean",
                      "desc": "If `true`, specifies that the OCSP status request extension will be added to the client hello and an `'OCSPResponse'` event will be emitted on the socket before establishing a secure communication."
                    },
                    {
                      "textRaw": "`minDHSize` {number} Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown. **Default:** `1024`.",
                      "name": "minDHSize",
                      "type": "number",
                      "default": "`1024`",
                      "desc": "Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown."
                    },
                    {
                      "textRaw": "`highWaterMark` {number} Consistent with the readable stream `highWaterMark` parameter. **Default:** `16 * 1024`.",
                      "name": "highWaterMark",
                      "type": "number",
                      "default": "`16 * 1024`",
                      "desc": "Consistent with the readable stream `highWaterMark` parameter."
                    },
                    {
                      "textRaw": "`timeout`: {number} If set and if a socket is created internally, will call `socket.setTimeout(timeout)` after the socket is created, but before it starts the connection.",
                      "name": "timeout",
                      "type": "number",
                      "desc": "If set and if a socket is created internally, will call `socket.setTimeout(timeout)` after the socket is created, but before it starts the connection."
                    },
                    {
                      "textRaw": "`secureContext`: TLS context object created with `tls.createSecureContext()`. If a `secureContext` is _not_ provided, one will be created by passing the entire `options` object to `tls.createSecureContext()`.",
                      "name": "secureContext",
                      "desc": "TLS context object created with `tls.createSecureContext()`. If a `secureContext` is _not_ provided, one will be created by passing the entire `options` object to `tls.createSecureContext()`."
                    },
                    {
                      "textRaw": "`onread` {Object} If the `socket` option is missing, incoming data is stored in a single `buffer` and passed to the supplied `callback` when data arrives on the socket, otherwise the option is ignored. See the `onread` option of `net.Socket` for details.",
                      "name": "onread",
                      "type": "Object",
                      "desc": "If the `socket` option is missing, incoming data is stored in a single `buffer` and passed to the supplied `callback` when data arrives on the socket, otherwise the option is ignored. See the `onread` option of `net.Socket` for details."
                    },
                    {
                      "textRaw": "...: `tls.createSecureContext()` options that are used if the `secureContext` option is missing, otherwise they are ignored.",
                      "name": "..",
                      "desc": "`tls.createSecureContext()` options that are used if the `secureContext` option is missing, otherwise they are ignored."
                    },
                    {
                      "textRaw": "...: Any `socket.connect()` option not already listed.",
                      "name": "..",
                      "desc": "Any `socket.connect()` option not already listed."
                    }
                  ]
                },
                {
                  "textRaw": "`callback` {Function}",
                  "name": "callback",
                  "type": "Function",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {tls.TLSSocket}",
                "name": "return",
                "type": "tls.TLSSocket"
              }
            }
          ],
          "desc": "<p>The <code>callback</code> function, if specified, will be added as a listener for the\n<a href=\"#event-secureconnect\"><code>'secureConnect'</code></a> event.</p>\n<p><code>tls.connect()</code> returns a <a href=\"#class-tlstlssocket\"><code>tls.TLSSocket</code></a> object.</p>\n<p>Unlike the <code>https</code> API, <code>tls.connect()</code> does not enable the\nSNI (Server Name Indication) extension by default, which may cause some\nservers to return an incorrect certificate or reject the connection\naltogether. To enable SNI, set the <code>servername</code> option in addition\nto <code>host</code>.</p>\n<p>The following illustrates a client for the echo server example from\n<a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a>:</p>\n<pre><code class=\"language-mjs\">// Assumes an echo server that is listening on port 8000.\nimport { connect } from 'node:tls';\nimport { readFileSync } from 'node:fs';\nimport { stdin } from 'node:process';\n\nconst options = {\n  // Necessary only if the server requires client certificate authentication.\n  key: readFileSync('client-key.pem'),\n  cert: readFileSync('client-cert.pem'),\n\n  // Necessary only if the server uses a self-signed certificate.\n  ca: [ readFileSync('server-cert.pem') ],\n\n  // Necessary only if the server's cert isn't for \"localhost\".\n  checkServerIdentity: () => { return null; },\n};\n\nconst socket = connect(8000, options, () => {\n  console.log('client connected',\n              socket.authorized ? 'authorized' : 'unauthorized');\n  stdin.pipe(socket);\n  stdin.resume();\n});\nsocket.setEncoding('utf8');\nsocket.on('data', (data) => {\n  console.log(data);\n});\nsocket.on('end', () => {\n  console.log('server ends connection');\n});\n</code></pre>\n<pre><code class=\"language-cjs\">// Assumes an echo server that is listening on port 8000.\nconst { connect } = require('node:tls');\nconst { readFileSync } = require('node:fs');\n\nconst options = {\n  // Necessary only if the server requires client certificate authentication.\n  key: readFileSync('client-key.pem'),\n  cert: readFileSync('client-cert.pem'),\n\n  // Necessary only if the server uses a self-signed certificate.\n  ca: [ readFileSync('server-cert.pem') ],\n\n  // Necessary only if the server's cert isn't for \"localhost\".\n  checkServerIdentity: () => { return null; },\n};\n\nconst socket = connect(8000, options, () => {\n  console.log('client connected',\n              socket.authorized ? 'authorized' : 'unauthorized');\n  process.stdin.pipe(socket);\n  process.stdin.resume();\n});\nsocket.setEncoding('utf8');\nsocket.on('data', (data) => {\n  console.log(data);\n});\nsocket.on('end', () => {\n  console.log('server ends connection');\n});\n</code></pre>\n<p>To generate the certificate and key for this example, run:</p>\n<pre><code class=\"language-bash\">openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \\\n  -keyout client-key.pem -out client-cert.pem\n</code></pre>\n<p>Then, to generate the <code>server-cert.pem</code> certificate for this example, run:</p>\n<pre><code class=\"language-bash\">openssl pkcs12 -certpbe AES-256-CBC -export -out server-cert.pem \\\n  -inkey client-key.pem -in client-cert.pem\n</code></pre>"
        },
        {
          "textRaw": "`tls.connect(path[, options][, callback])`",
          "name": "connect",
          "type": "method",
          "meta": {
            "added": [
              "v0.11.3"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`path` {string} Default value for `options.path`.",
                  "name": "path",
                  "type": "string",
                  "desc": "Default value for `options.path`."
                },
                {
                  "textRaw": "`options` {Object} See `tls.connect()`.",
                  "name": "options",
                  "type": "Object",
                  "desc": "See `tls.connect()`.",
                  "optional": true
                },
                {
                  "textRaw": "`callback` {Function} See `tls.connect()`.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "See `tls.connect()`.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {tls.TLSSocket}",
                "name": "return",
                "type": "tls.TLSSocket"
              }
            }
          ],
          "desc": "<p>Same as <a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a> except that <code>path</code> can be provided\nas an argument instead of an option.</p>\n<p>A path option, if specified, will take precedence over the path argument.</p>"
        },
        {
          "textRaw": "`tls.connect(port[, host][, options][, callback])`",
          "name": "connect",
          "type": "method",
          "meta": {
            "added": [
              "v0.11.3"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`port` {number} Default value for `options.port`.",
                  "name": "port",
                  "type": "number",
                  "desc": "Default value for `options.port`."
                },
                {
                  "textRaw": "`host` {string} Default value for `options.host`.",
                  "name": "host",
                  "type": "string",
                  "desc": "Default value for `options.host`.",
                  "optional": true
                },
                {
                  "textRaw": "`options` {Object} See `tls.connect()`.",
                  "name": "options",
                  "type": "Object",
                  "desc": "See `tls.connect()`.",
                  "optional": true
                },
                {
                  "textRaw": "`callback` {Function} See `tls.connect()`.",
                  "name": "callback",
                  "type": "Function",
                  "desc": "See `tls.connect()`.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {tls.TLSSocket}",
                "name": "return",
                "type": "tls.TLSSocket"
              }
            }
          ],
          "desc": "<p>Same as <a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a> except that <code>port</code> and <code>host</code> can be provided\nas arguments instead of options.</p>\n<p>A port or host option, if specified, will take precedence over any port or host\nargument.</p>"
        },
        {
          "textRaw": "`tls.createSecureContext([options])`",
          "name": "createSecureContext",
          "type": "method",
          "meta": {
            "added": [
              "v0.11.13"
            ],
            "changes": [
              {
                "version": [
                  "v22.9.0",
                  "v20.18.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/54790",
                "description": "The `allowPartialTrustChain` option has been added."
              },
              {
                "version": [
                  "v22.4.0",
                  "v20.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/53329",
                "description": "The `clientCertEngine`, `privateKeyEngine` and `privateKeyIdentifier` options depend on custom engine support in OpenSSL which is deprecated in OpenSSL 3."
              },
              {
                "version": [
                  "v19.8.0",
                  "v18.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/46978",
                "description": "The `dhparam` option can now be set to `'auto'` to enable DHE with appropriate well-known parameters."
              },
              {
                "version": "v12.12.0",
                "pr-url": "https://github.com/nodejs/node/pull/28973",
                "description": "Added `privateKeyIdentifier` and `privateKeyEngine` options to get private key from an OpenSSL engine."
              },
              {
                "version": "v12.11.0",
                "pr-url": "https://github.com/nodejs/node/pull/29598",
                "description": "Added `sigalgs` option to override supported signature algorithms."
              },
              {
                "version": "v12.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/26209",
                "description": "TLSv1.3 support added."
              },
              {
                "version": "v11.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/24733",
                "description": "The `ca:` option now supports `BEGIN TRUSTED CERTIFICATE`."
              },
              {
                "version": [
                  "v11.4.0",
                  "v10.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/24405",
                "description": "The `minVersion` and `maxVersion` can be used to restrict the allowed TLS protocol versions."
              },
              {
                "version": "v10.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/19794",
                "description": "The `ecdhCurve` cannot be set to `false` anymore due to a change in OpenSSL."
              },
              {
                "version": "v9.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/14903",
                "description": "The `options` parameter can now include `clientCertEngine`."
              },
              {
                "version": "v9.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/15206",
                "description": "The `ecdhCurve` option can now be multiple `':'` separated curve names or `'auto'`."
              },
              {
                "version": "v7.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/10294",
                "description": "If the `key` option is an array, individual entries do not need a `passphrase` property anymore. `Array` entries can also just be `string`s or `Buffer`s now."
              },
              {
                "version": "v5.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/4099",
                "description": "The `ca` option can now be a single string containing multiple CA certificates."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`allowPartialTrustChain` {boolean} Treat intermediate (non-self-signed) certificates in the trust CA certificate list as trusted.",
                      "name": "allowPartialTrustChain",
                      "type": "boolean",
                      "desc": "Treat intermediate (non-self-signed) certificates in the trust CA certificate list as trusted."
                    },
                    {
                      "textRaw": "`ca` {string|string[]|Buffer|Buffer[]} Optionally override the trusted CA certificates. If not specified, the CA certificates trusted by default are the same as the ones returned by `tls.getCACertificates()` using the `default` type. If specified, the default list would be completely replaced (instead of being concatenated) by the certificates in the `ca` option. Users need to concatenate manually if they wish to add additional certificates instead of completely overriding the default. The value can be a string or `Buffer`, or an `Array` of strings and/or `Buffer`s. Any string or `Buffer` can contain multiple PEM CAs concatenated together. The peer's certificate must be chainable to a CA trusted by the server for the connection to be authenticated. When using certificates that are not chainable to a well-known CA, the certificate's CA must be explicitly specified as a trusted or the connection will fail to authenticate. If the peer uses a certificate that doesn't match or chain to one of the default CAs, use the `ca` option to provide a CA certificate that the peer's certificate can match or chain to. For self-signed certificates, the certificate is its own CA, and must be provided. For PEM encoded certificates, supported types are \"TRUSTED CERTIFICATE\", \"X509 CERTIFICATE\", and \"CERTIFICATE\".",
                      "name": "ca",
                      "type": "string|string[]|Buffer|Buffer[]",
                      "desc": "Optionally override the trusted CA certificates. If not specified, the CA certificates trusted by default are the same as the ones returned by `tls.getCACertificates()` using the `default` type. If specified, the default list would be completely replaced (instead of being concatenated) by the certificates in the `ca` option. Users need to concatenate manually if they wish to add additional certificates instead of completely overriding the default. The value can be a string or `Buffer`, or an `Array` of strings and/or `Buffer`s. Any string or `Buffer` can contain multiple PEM CAs concatenated together. The peer's certificate must be chainable to a CA trusted by the server for the connection to be authenticated. When using certificates that are not chainable to a well-known CA, the certificate's CA must be explicitly specified as a trusted or the connection will fail to authenticate. If the peer uses a certificate that doesn't match or chain to one of the default CAs, use the `ca` option to provide a CA certificate that the peer's certificate can match or chain to. For self-signed certificates, the certificate is its own CA, and must be provided. For PEM encoded certificates, supported types are \"TRUSTED CERTIFICATE\", \"X509 CERTIFICATE\", and \"CERTIFICATE\"."
                    },
                    {
                      "textRaw": "`cert` {string|string[]|Buffer|Buffer[]} Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private `key`, followed by the PEM formatted intermediate certificates (if any), in order, and not including the root CA (the root CA must be pre-known to the peer, see `ca`). When providing multiple cert chains, they do not have to be in the same order as their private keys in `key`. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.",
                      "name": "cert",
                      "type": "string|string[]|Buffer|Buffer[]",
                      "desc": "Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private `key`, followed by the PEM formatted intermediate certificates (if any), in order, and not including the root CA (the root CA must be pre-known to the peer, see `ca`). When providing multiple cert chains, they do not have to be in the same order as their private keys in `key`. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail."
                    },
                    {
                      "textRaw": "`sigalgs` {string} Colon-separated list of supported signature algorithms. The list can contain digest algorithms (`SHA256`, `MD5` etc.), public key algorithms (`RSA-PSS`, `ECDSA` etc.), combination of both (e.g 'RSA+SHA384') or TLS v1.3 scheme names (e.g. `rsa_pss_pss_sha512`). See OpenSSL man pages for more info.",
                      "name": "sigalgs",
                      "type": "string",
                      "desc": "Colon-separated list of supported signature algorithms. The list can contain digest algorithms (`SHA256`, `MD5` etc.), public key algorithms (`RSA-PSS`, `ECDSA` etc.), combination of both (e.g 'RSA+SHA384') or TLS v1.3 scheme names (e.g. `rsa_pss_pss_sha512`). See OpenSSL man pages for more info."
                    },
                    {
                      "textRaw": "`ciphers` {string} Cipher suite specification, replacing the default. For more information, see Modifying the default TLS cipher suite. Permitted ciphers can be obtained via `tls.getCiphers()`. Cipher names must be uppercased in order for OpenSSL to accept them.",
                      "name": "ciphers",
                      "type": "string",
                      "desc": "Cipher suite specification, replacing the default. For more information, see Modifying the default TLS cipher suite. Permitted ciphers can be obtained via `tls.getCiphers()`. Cipher names must be uppercased in order for OpenSSL to accept them."
                    },
                    {
                      "textRaw": "`clientCertEngine` {string} Name of an OpenSSL engine which can provide the client certificate. **Deprecated.**",
                      "name": "clientCertEngine",
                      "type": "string",
                      "desc": "Name of an OpenSSL engine which can provide the client certificate. **Deprecated.**"
                    },
                    {
                      "textRaw": "`crl` {string|string[]|Buffer|Buffer[]} PEM formatted CRLs (Certificate Revocation Lists).",
                      "name": "crl",
                      "type": "string|string[]|Buffer|Buffer[]",
                      "desc": "PEM formatted CRLs (Certificate Revocation Lists)."
                    },
                    {
                      "textRaw": "`dhparam` {string|Buffer} `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. ECDHE-based perfect forward secrecy will still be available.",
                      "name": "dhparam",
                      "type": "string|Buffer",
                      "desc": "`'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. ECDHE-based perfect forward secrecy will still be available."
                    },
                    {
                      "textRaw": "`ecdhCurve` {string} A string describing a named curve or a colon separated list of curve NIDs or names, for example `P-521:P-384:P-256`, to use for ECDH key agreement. Set to `auto` to select the curve automatically. Use `crypto.getCurves()` to obtain a list of available curve names. On recent releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve. **Default:** `tls.DEFAULT_ECDH_CURVE`.",
                      "name": "ecdhCurve",
                      "type": "string",
                      "default": "`tls.DEFAULT_ECDH_CURVE`",
                      "desc": "A string describing a named curve or a colon separated list of curve NIDs or names, for example `P-521:P-384:P-256`, to use for ECDH key agreement. Set to `auto` to select the curve automatically. Use `crypto.getCurves()` to obtain a list of available curve names. On recent releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve."
                    },
                    {
                      "textRaw": "`honorCipherOrder` {boolean} Attempt to use the server's cipher suite preferences instead of the client's. When `true`, causes `SSL_OP_CIPHER_SERVER_PREFERENCE` to be set in `secureOptions`, see OpenSSL Options for more information.",
                      "name": "honorCipherOrder",
                      "type": "boolean",
                      "desc": "Attempt to use the server's cipher suite preferences instead of the client's. When `true`, causes `SSL_OP_CIPHER_SERVER_PREFERENCE` to be set in `secureOptions`, see OpenSSL Options for more information."
                    },
                    {
                      "textRaw": "`key` {string|string[]|Buffer|Buffer[]|Object[]} Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with `options.passphrase`. Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or buffers, or an array of objects in the form `{pem: <string|buffer>[, passphrase: <string>]}`. The object form can only occur in an array. `object.passphrase` is optional. Encrypted keys will be decrypted with `object.passphrase` if provided, or `options.passphrase` if it is not.",
                      "name": "key",
                      "type": "string|string[]|Buffer|Buffer[]|Object[]",
                      "desc": "Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with `options.passphrase`. Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or buffers, or an array of objects in the form `{pem: <string|buffer>[, passphrase: <string>]}`. The object form can only occur in an array. `object.passphrase` is optional. Encrypted keys will be decrypted with `object.passphrase` if provided, or `options.passphrase` if it is not."
                    },
                    {
                      "textRaw": "`privateKeyEngine` {string} Name of an OpenSSL engine to get private key from. Should be used together with `privateKeyIdentifier`. **Deprecated.**",
                      "name": "privateKeyEngine",
                      "type": "string",
                      "desc": "Name of an OpenSSL engine to get private key from. Should be used together with `privateKeyIdentifier`. **Deprecated.**"
                    },
                    {
                      "textRaw": "`privateKeyIdentifier` {string} Identifier of a private key managed by an OpenSSL engine. Should be used together with `privateKeyEngine`. Should not be set together with `key`, because both options define a private key in different ways. **Deprecated.**",
                      "name": "privateKeyIdentifier",
                      "type": "string",
                      "desc": "Identifier of a private key managed by an OpenSSL engine. Should be used together with `privateKeyEngine`. Should not be set together with `key`, because both options define a private key in different ways. **Deprecated.**"
                    },
                    {
                      "textRaw": "`maxVersion` {string} Optionally set the maximum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option; use one or the other. **Default:** `tls.DEFAULT_MAX_VERSION`.",
                      "name": "maxVersion",
                      "type": "string",
                      "default": "`tls.DEFAULT_MAX_VERSION`",
                      "desc": "Optionally set the maximum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option; use one or the other."
                    },
                    {
                      "textRaw": "`minVersion` {string} Optionally set the minimum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option; use one or the other. Avoid setting to less than TLSv1.2, but it may be required for interoperability. Versions before TLSv1.2 may require downgrading the OpenSSL Security Level. **Default:** `tls.DEFAULT_MIN_VERSION`.",
                      "name": "minVersion",
                      "type": "string",
                      "default": "`tls.DEFAULT_MIN_VERSION`",
                      "desc": "Optionally set the minimum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option; use one or the other. Avoid setting to less than TLSv1.2, but it may be required for interoperability. Versions before TLSv1.2 may require downgrading the OpenSSL Security Level."
                    },
                    {
                      "textRaw": "`passphrase` {string} Shared passphrase used for a single private key and/or a PFX.",
                      "name": "passphrase",
                      "type": "string",
                      "desc": "Shared passphrase used for a single private key and/or a PFX."
                    },
                    {
                      "textRaw": "`pfx` {string|string[]|Buffer|Buffer[]|Object[]} PFX or PKCS12 encoded private key and certificate chain. `pfx` is an alternative to providing `key` and `cert` individually. PFX is usually encrypted, if it is, `passphrase` will be used to decrypt it. Multiple PFX can be provided either as an array of unencrypted PFX buffers, or an array of objects in the form `{buf: <string|buffer>[, passphrase: <string>]}`. The object form can only occur in an array. `object.passphrase` is optional. Encrypted PFX will be decrypted with `object.passphrase` if provided, or `options.passphrase` if it is not.",
                      "name": "pfx",
                      "type": "string|string[]|Buffer|Buffer[]|Object[]",
                      "desc": "PFX or PKCS12 encoded private key and certificate chain. `pfx` is an alternative to providing `key` and `cert` individually. PFX is usually encrypted, if it is, `passphrase` will be used to decrypt it. Multiple PFX can be provided either as an array of unencrypted PFX buffers, or an array of objects in the form `{buf: <string|buffer>[, passphrase: <string>]}`. The object form can only occur in an array. `object.passphrase` is optional. Encrypted PFX will be decrypted with `object.passphrase` if provided, or `options.passphrase` if it is not."
                    },
                    {
                      "textRaw": "`secureOptions` {number} Optionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the `SSL_OP_*` options from OpenSSL Options.",
                      "name": "secureOptions",
                      "type": "number",
                      "desc": "Optionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the `SSL_OP_*` options from OpenSSL Options."
                    },
                    {
                      "textRaw": "`secureProtocol` {string} Legacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use `minVersion` and `maxVersion` instead. The possible values are listed as SSL_METHODS, use the function names as strings. For example, use `'TLSv1_1_method'` to force TLS version 1.1, or `'TLS_method'` to allow any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. **Default:** none, see `minVersion`.",
                      "name": "secureProtocol",
                      "type": "string",
                      "default": "none, see `minVersion`",
                      "desc": "Legacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use `minVersion` and `maxVersion` instead. The possible values are listed as SSL_METHODS, use the function names as strings. For example, use `'TLSv1_1_method'` to force TLS version 1.1, or `'TLS_method'` to allow any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability."
                    },
                    {
                      "textRaw": "`sessionIdContext` {string} Opaque identifier used by servers to ensure session state is not shared between applications. Unused by clients.",
                      "name": "sessionIdContext",
                      "type": "string",
                      "desc": "Opaque identifier used by servers to ensure session state is not shared between applications. Unused by clients."
                    },
                    {
                      "textRaw": "`ticketKeys` {Buffer} 48-bytes of cryptographically strong pseudorandom data. See Session Resumption for more information.",
                      "name": "ticketKeys",
                      "type": "Buffer",
                      "desc": "48-bytes of cryptographically strong pseudorandom data. See Session Resumption for more information."
                    },
                    {
                      "textRaw": "`sessionTimeout` {number} The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information. **Default:** `300`.",
                      "name": "sessionTimeout",
                      "type": "number",
                      "default": "`300`",
                      "desc": "The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p><a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a> sets the default value of the <code>honorCipherOrder</code> option\nto <code>true</code>, other APIs that create secure contexts leave it unset.</p>\n<p><a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a> uses a 128 bit truncated SHA1 hash value generated\nfrom <code>process.argv</code> as the default value of the <code>sessionIdContext</code> option, other\nAPIs that create secure contexts have no default value.</p>\n<p>The <code>tls.createSecureContext()</code> method creates a <code>SecureContext</code> object. It is\nusable as an argument to several <code>tls</code> APIs, such as <a href=\"#serveraddcontexthostname-context\"><code>server.addContext()</code></a>,\nbut has no public methods. The <a href=\"#class-tlsserver\"><code>tls.Server</code></a> constructor and the\n<a href=\"#tlscreateserveroptions-secureconnectionlistener\"><code>tls.createServer()</code></a> method do not support the <code>secureContext</code> option.</p>\n<p>A key is <em>required</em> for ciphers that use certificates. Either <code>key</code> or\n<code>pfx</code> can be used to provide it.</p>\n<p>If the <code>ca</code> option is not given, then Node.js will default to using\n<a href=\"https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt\">Mozilla's publicly trusted list of CAs</a>.</p>\n<p>Custom DHE parameters are discouraged in favor of the new <code>dhparam: 'auto'</code>\noption. When set to <code>'auto'</code>, well-known DHE parameters of sufficient strength\nwill be selected automatically. Otherwise, if necessary, <code>openssl dhparam</code> can\nbe used to create custom parameters. The key length must be greater than or\nequal to 1024 bits or else an error will be thrown. Although 1024 bits is\npermissible, use 2048 bits or larger for stronger security.</p>"
        },
        {
          "textRaw": "`tls.createServer([options][, secureConnectionListener])`",
          "name": "createServer",
          "type": "method",
          "meta": {
            "added": [
              "v0.3.2"
            ],
            "changes": [
              {
                "version": [
                  "v22.4.0",
                  "v20.16.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/53329",
                "description": "The `clientCertEngine` option depends on custom engine support in OpenSSL which is deprecated in OpenSSL 3."
              },
              {
                "version": [
                  "v20.4.0",
                  "v18.19.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/45190",
                "description": "The `options` parameter can now include `ALPNCallback`."
              },
              {
                "version": "v19.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/44031",
                "description": "If `ALPNProtocols` is set, incoming connections that send an ALPN extension with no supported protocols are terminated with a fatal `no_application_protocol` alert."
              },
              {
                "version": "v12.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/27665",
                "description": "The `options` parameter now supports `net.createServer()` options."
              },
              {
                "version": "v9.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/14903",
                "description": "The `options` parameter can now include `clientCertEngine`."
              },
              {
                "version": "v8.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/11984",
                "description": "The `ALPNProtocols` option can be a `TypedArray` or `DataView` now."
              },
              {
                "version": "v5.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/2564",
                "description": "ALPN options are supported now."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`ALPNProtocols` {string[]|Buffer|TypedArray|DataView} An array of strings, or a single `Buffer`, `TypedArray`, or `DataView` containing the supported ALPN protocols. Buffers should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['hello', 'world']`. (Protocols should be ordered by their priority.)",
                      "name": "ALPNProtocols",
                      "type": "string[]|Buffer|TypedArray|DataView",
                      "desc": "An array of strings, or a single `Buffer`, `TypedArray`, or `DataView` containing the supported ALPN protocols. Buffers should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['hello', 'world']`. (Protocols should be ordered by their priority.)"
                    },
                    {
                      "textRaw": "`ALPNCallback` {Function} If set, this will be called when a client opens a connection using the ALPN extension. One argument will be passed to the callback: an object containing `servername` and `protocols` fields, respectively containing the server name from the SNI extension (if any) and an array of ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`, which will be returned to the client as the selected ALPN protocol, or `undefined`, to reject the connection with a fatal alert. If a string is returned that does not match one of the client's ALPN protocols, an error will be thrown. This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.",
                      "name": "ALPNCallback",
                      "type": "Function",
                      "desc": "If set, this will be called when a client opens a connection using the ALPN extension. One argument will be passed to the callback: an object containing `servername` and `protocols` fields, respectively containing the server name from the SNI extension (if any) and an array of ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`, which will be returned to the client as the selected ALPN protocol, or `undefined`, to reject the connection with a fatal alert. If a string is returned that does not match one of the client's ALPN protocols, an error will be thrown. This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error."
                    },
                    {
                      "textRaw": "`clientCertEngine` {string} Name of an OpenSSL engine which can provide the client certificate. **Deprecated.**",
                      "name": "clientCertEngine",
                      "type": "string",
                      "desc": "Name of an OpenSSL engine which can provide the client certificate. **Deprecated.**"
                    },
                    {
                      "textRaw": "`enableTrace` {boolean} If `true`, `tls.TLSSocket.enableTrace()` will be called on new connections. Tracing can be enabled after the secure connection is established, but this option must be used to trace the secure connection setup. **Default:** `false`.",
                      "name": "enableTrace",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If `true`, `tls.TLSSocket.enableTrace()` will be called on new connections. Tracing can be enabled after the secure connection is established, but this option must be used to trace the secure connection setup."
                    },
                    {
                      "textRaw": "`handshakeTimeout` {number} Abort the connection if the SSL/TLS handshake does not finish in the specified number of milliseconds. A `'tlsClientError'` is emitted on the `tls.Server` object whenever a handshake times out. **Default:** `120000` (120 seconds).",
                      "name": "handshakeTimeout",
                      "type": "number",
                      "default": "`120000` (120 seconds)",
                      "desc": "Abort the connection if the SSL/TLS handshake does not finish in the specified number of milliseconds. A `'tlsClientError'` is emitted on the `tls.Server` object whenever a handshake times out."
                    },
                    {
                      "textRaw": "`rejectUnauthorized` {boolean} If not `false` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if `requestCert` is `true`. **Default:** `true`.",
                      "name": "rejectUnauthorized",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "If not `false` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if `requestCert` is `true`."
                    },
                    {
                      "textRaw": "`requestCert` {boolean} If `true` the server will request a certificate from clients that connect and attempt to verify that certificate. **Default:** `false`.",
                      "name": "requestCert",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If `true` the server will request a certificate from clients that connect and attempt to verify that certificate."
                    },
                    {
                      "textRaw": "`sessionTimeout` {number} The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information. **Default:** `300`.",
                      "name": "sessionTimeout",
                      "type": "number",
                      "default": "`300`",
                      "desc": "The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information."
                    },
                    {
                      "textRaw": "`SNICallback(servername, callback)` {Function} A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `callback`. `callback` is an error-first callback that takes two optional arguments: `error` and `ctx`. `ctx`, if provided, is a `SecureContext` instance. `tls.createSecureContext()` can be used to get a proper `SecureContext`. If `callback` is called with a falsy `ctx` argument, the default secure context of the server will be used. If `SNICallback` wasn't provided the default callback with high-level API will be used (see below).",
                      "name": "SNICallback(servername,",
                      "desc": "callback)` {Function} A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `callback`. `callback` is an error-first callback that takes two optional arguments: `error` and `ctx`. `ctx`, if provided, is a `SecureContext` instance. `tls.createSecureContext()` can be used to get a proper `SecureContext`. If `callback` is called with a falsy `ctx` argument, the default secure context of the server will be used. If `SNICallback` wasn't provided the default callback with high-level API will be used (see below)."
                    },
                    {
                      "textRaw": "`ticketKeys` {Buffer} 48-bytes of cryptographically strong pseudorandom data. See Session Resumption for more information.",
                      "name": "ticketKeys",
                      "type": "Buffer",
                      "desc": "48-bytes of cryptographically strong pseudorandom data. See Session Resumption for more information."
                    },
                    {
                      "textRaw": "`pskCallback` {Function} For TLS-PSK negotiation, see Pre-shared keys.",
                      "name": "pskCallback",
                      "type": "Function",
                      "desc": "For TLS-PSK negotiation, see Pre-shared keys."
                    },
                    {
                      "textRaw": "`pskIdentityHint` {string} optional hint to send to a client to help with selecting the identity during TLS-PSK negotiation. Will be ignored in TLS 1.3. Upon failing to set pskIdentityHint `'tlsClientError'` will be emitted with `'ERR_TLS_PSK_SET_IDENTITY_HINT_FAILED'` code.",
                      "name": "pskIdentityHint",
                      "type": "string",
                      "desc": "optional hint to send to a client to help with selecting the identity during TLS-PSK negotiation. Will be ignored in TLS 1.3. Upon failing to set pskIdentityHint `'tlsClientError'` will be emitted with `'ERR_TLS_PSK_SET_IDENTITY_HINT_FAILED'` code."
                    },
                    {
                      "textRaw": "...: Any `tls.createSecureContext()` option can be provided. For servers, the identity options (`pfx`, `key`/`cert`, or `pskCallback`) are usually required.",
                      "name": "..",
                      "desc": "Any `tls.createSecureContext()` option can be provided. For servers, the identity options (`pfx`, `key`/`cert`, or `pskCallback`) are usually required."
                    },
                    {
                      "textRaw": "...: Any `net.createServer()` option can be provided.",
                      "name": "..",
                      "desc": "Any `net.createServer()` option can be provided."
                    }
                  ],
                  "optional": true
                },
                {
                  "textRaw": "`secureConnectionListener` {Function}",
                  "name": "secureConnectionListener",
                  "type": "Function",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {tls.Server}",
                "name": "return",
                "type": "tls.Server"
              }
            }
          ],
          "desc": "<p>Creates a new <a href=\"#class-tlsserver\"><code>tls.Server</code></a>. The <code>secureConnectionListener</code>, if provided, is\nautomatically set as a listener for the <a href=\"#event-secureconnection\"><code>'secureConnection'</code></a> event.</p>\n<p>The <code>ticketKeys</code> options is automatically shared between <code>node:cluster</code> module\nworkers.</p>\n<p>The following illustrates a simple echo server:</p>\n<pre><code class=\"language-mjs\">import { createServer } from 'node:tls';\nimport { readFileSync } from 'node:fs';\n\nconst options = {\n  key: readFileSync('server-key.pem'),\n  cert: readFileSync('server-cert.pem'),\n\n  // This is necessary only if using client certificate authentication.\n  requestCert: true,\n\n  // This is necessary only if the client uses a self-signed certificate.\n  ca: [ readFileSync('client-cert.pem') ],\n};\n\nconst server = createServer(options, (socket) => {\n  console.log('server connected',\n              socket.authorized ? 'authorized' : 'unauthorized');\n  socket.write('welcome!\\n');\n  socket.setEncoding('utf8');\n  socket.pipe(socket);\n});\nserver.listen(8000, () => {\n  console.log('server bound');\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { createServer } = require('node:tls');\nconst { readFileSync } = require('node:fs');\n\nconst options = {\n  key: readFileSync('server-key.pem'),\n  cert: readFileSync('server-cert.pem'),\n\n  // This is necessary only if using client certificate authentication.\n  requestCert: true,\n\n  // This is necessary only if the client uses a self-signed certificate.\n  ca: [ readFileSync('client-cert.pem') ],\n};\n\nconst server = createServer(options, (socket) => {\n  console.log('server connected',\n              socket.authorized ? 'authorized' : 'unauthorized');\n  socket.write('welcome!\\n');\n  socket.setEncoding('utf8');\n  socket.pipe(socket);\n});\nserver.listen(8000, () => {\n  console.log('server bound');\n});\n</code></pre>\n<p>To generate the certificate and key for this example, run:</p>\n<pre><code class=\"language-bash\">openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \\\n  -keyout server-key.pem -out server-cert.pem\n</code></pre>\n<p>Then, to generate the <code>client-cert.pem</code> certificate for this example, run:</p>\n<pre><code class=\"language-bash\">openssl pkcs12 -certpbe AES-256-CBC -export -out client-cert.pem \\\n  -inkey server-key.pem -in server-cert.pem\n</code></pre>\n<p>The server can be tested by connecting to it using the example client from\n<a href=\"#tlsconnectoptions-callback\"><code>tls.connect()</code></a>.</p>"
        },
        {
          "textRaw": "`tls.setDefaultCACertificates(certs)`",
          "name": "setDefaultCACertificates",
          "type": "method",
          "meta": {
            "added": [
              "v24.5.0",
              "v22.19.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`certs` {string[]|ArrayBufferView[]} An array of CA certificates in PEM format.",
                  "name": "certs",
                  "type": "string[]|ArrayBufferView[]",
                  "desc": "An array of CA certificates in PEM format."
                }
              ]
            }
          ],
          "desc": "<p>Sets the default CA certificates used by Node.js TLS clients. If the provided\ncertificates are parsed successfully, they will become the default CA\ncertificate list returned by <a href=\"#tlsgetcacertificatestype\"><code>tls.getCACertificates()</code></a> and used\nby subsequent TLS connections that don't specify their own CA certificates.\nThe certificates will be deduplicated before being set as the default.</p>\n<p>This function only affects the current Node.js thread. Previous\nsessions cached by the HTTPS agent won't be affected by this change, so\nthis method should be called before any unwanted cachable TLS connections are\nmade.</p>\n<p>To use system CA certificates as the default:</p>\n<pre><code class=\"language-cjs\">const tls = require('node:tls');\ntls.setDefaultCACertificates(tls.getCACertificates('system'));\n</code></pre>\n<pre><code class=\"language-mjs\">import tls from 'node:tls';\ntls.setDefaultCACertificates(tls.getCACertificates('system'));\n</code></pre>\n<p>This function completely replaces the default CA certificate list. To add additional\ncertificates to the existing defaults, get the current certificates and append to them:</p>\n<pre><code class=\"language-cjs\">const tls = require('node:tls');\nconst currentCerts = tls.getCACertificates('default');\nconst additionalCerts = ['-----BEGIN CERTIFICATE-----\\n...'];\ntls.setDefaultCACertificates([...currentCerts, ...additionalCerts]);\n</code></pre>\n<pre><code class=\"language-mjs\">import tls from 'node:tls';\nconst currentCerts = tls.getCACertificates('default');\nconst additionalCerts = ['-----BEGIN CERTIFICATE-----\\n...'];\ntls.setDefaultCACertificates([...currentCerts, ...additionalCerts]);\n</code></pre>"
        },
        {
          "textRaw": "`tls.getCACertificates([type])`",
          "name": "getCACertificates",
          "type": "method",
          "meta": {
            "added": [
              "v23.10.0",
              "v22.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`type` {string|undefined} The type of CA certificates that will be returned. Valid values are `\"default\"`, `\"system\"`, `\"bundled\"` and `\"extra\"`. **Default:** `\"default\"`.",
                  "name": "type",
                  "type": "string|undefined",
                  "default": "`\"default\"`",
                  "desc": "The type of CA certificates that will be returned. Valid values are `\"default\"`, `\"system\"`, `\"bundled\"` and `\"extra\"`.",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {string[]} An array of PEM-encoded certificates. The array may contain duplicates if the same certificate is repeatedly stored in multiple sources.",
                "name": "return",
                "type": "string[]",
                "desc": "An array of PEM-encoded certificates. The array may contain duplicates if the same certificate is repeatedly stored in multiple sources."
              }
            }
          ],
          "desc": "<p>Returns an array containing the CA certificates from various sources, depending on <code>type</code>:</p>\n<ul>\n<li><code>\"default\"</code>: return the CA certificates that will be used by the Node.js TLS clients by default.\n<ul>\n<li>When <a href=\"cli.html#--use-bundled-ca---use-openssl-ca\"><code>--use-bundled-ca</code></a> is enabled (default), or <a href=\"cli.html#--use-bundled-ca---use-openssl-ca\"><code>--use-openssl-ca</code></a> is not enabled,\nthis would include CA certificates from the bundled Mozilla CA store.</li>\n<li>When <a href=\"cli.html#--use-system-ca\"><code>--use-system-ca</code></a> is enabled, this would also include certificates from the system's\ntrusted store.</li>\n<li>When <a href=\"cli.html#node_extra_ca_certsfile\"><code>NODE_EXTRA_CA_CERTS</code></a> is used, this would also include certificates loaded from the specified\nfile.</li>\n</ul>\n</li>\n<li><code>\"system\"</code>: return the CA certificates that are loaded from the system's trusted store, according\nto rules set by <a href=\"cli.html#--use-system-ca\"><code>--use-system-ca</code></a>. This can be used to get the certificates from the system\nwhen <a href=\"cli.html#--use-system-ca\"><code>--use-system-ca</code></a> is not enabled.</li>\n<li><code>\"bundled\"</code>: return the CA certificates from the bundled Mozilla CA store. This would be the same\nas <a href=\"#tlsrootcertificates\"><code>tls.rootCertificates</code></a>.</li>\n<li><code>\"extra\"</code>: return the CA certificates loaded from <a href=\"cli.html#node_extra_ca_certsfile\"><code>NODE_EXTRA_CA_CERTS</code></a>. It's an empty array if\n<a href=\"cli.html#node_extra_ca_certsfile\"><code>NODE_EXTRA_CA_CERTS</code></a> is not set.</li>\n</ul>"
        },
        {
          "textRaw": "`tls.getCiphers()`",
          "name": "getCiphers",
          "type": "method",
          "meta": {
            "added": [
              "v0.10.2"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {string[]}",
                "name": "return",
                "type": "string[]"
              }
            }
          ],
          "desc": "<p>Returns an array with the names of the supported TLS ciphers. The names are\nlower-case for historical reasons, but must be uppercased to be used in\nthe <code>ciphers</code> option of <a href=\"#tlscreatesecurecontextoptions\"><code>tls.createSecureContext()</code></a>.</p>\n<p>Not all supported ciphers are enabled by default. See\n<a href=\"#modifying-the-default-tls-cipher-suite\">Modifying the default TLS cipher suite</a>.</p>\n<p>Cipher names that start with <code>'tls_'</code> are for TLSv1.3, all the others are for\nTLSv1.2 and below.</p>\n<pre><code class=\"language-js\">console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...]\n</code></pre>"
        }
      ],
      "properties": [
        {
          "textRaw": "Type: {string[]}",
          "name": "rootCertificates",
          "type": "string[]",
          "meta": {
            "added": [
              "v12.3.0"
            ],
            "changes": []
          },
          "desc": "<p>An immutable array of strings representing the root certificates (in PEM format)\nfrom the bundled Mozilla CA store as supplied by the current Node.js version.</p>\n<p>The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store\nthat is fixed at release time. It is identical on all supported platforms.</p>\n<p>To get the actual CA certificates used by the current Node.js instance, which\nmay include certificates loaded from the system store (if <code>--use-system-ca</code> is used)\nor loaded from a file indicated by <code>NODE_EXTRA_CA_CERTS</code>, use\n<a href=\"#tlsgetcacertificatestype\"><code>tls.getCACertificates()</code></a>.</p>"
        },
        {
          "textRaw": "`tls.DEFAULT_ECDH_CURVE`",
          "name": "DEFAULT_ECDH_CURVE",
          "type": "property",
          "meta": {
            "added": [
              "v0.11.13"
            ],
            "changes": [
              {
                "version": "v10.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/16853",
                "description": "Default value changed to `'auto'`."
              }
            ]
          },
          "desc": "<p>The default curve name to use for ECDH key agreement in a tls server. The\ndefault value is <code>'auto'</code>. See <a href=\"#tlscreatesecurecontextoptions\"><code>tls.createSecureContext()</code></a> for further\ninformation.</p>"
        },
        {
          "textRaw": "Type: {string} The default value of the `maxVersion` option of `tls.createSecureContext()`. It can be assigned any of the supported TLS protocol versions, `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.3'`, unless changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used.",
          "name": "DEFAULT_MAX_VERSION",
          "type": "string",
          "meta": {
            "added": [
              "v11.4.0"
            ],
            "changes": []
          },
          "default": "`'TLSv1.3'`, unless changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used",
          "desc": "The default value of the `maxVersion` option of `tls.createSecureContext()`. It can be assigned any of the supported TLS protocol versions, `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`."
        },
        {
          "textRaw": "Type: {string} The default value of the `minVersion` option of `tls.createSecureContext()`. It can be assigned any of the supported TLS protocol versions, `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Versions before TLSv1.2 may require downgrading the OpenSSL Security Level. **Default:** `'TLSv1.2'`, unless changed using CLI options. Using `--tls-min-v1.0` sets the default to `'TLSv1'`. Using `--tls-min-v1.1` sets the default to `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the lowest minimum is used.",
          "name": "DEFAULT_MIN_VERSION",
          "type": "string",
          "meta": {
            "added": [
              "v11.4.0"
            ],
            "changes": []
          },
          "default": "`'TLSv1.2'`, unless changed using CLI options. Using `--tls-min-v1.0` sets the default to `'TLSv1'`. Using `--tls-min-v1.1` sets the default to `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the lowest minimum is used",
          "desc": "The default value of the `minVersion` option of `tls.createSecureContext()`. It can be assigned any of the supported TLS protocol versions, `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Versions before TLSv1.2 may require downgrading the OpenSSL Security Level."
        },
        {
          "textRaw": "Type: {string} The default value of the `ciphers` option of `tls.createSecureContext()`. It can be assigned any of the supported OpenSSL ciphers. Defaults to the content of `crypto.constants.defaultCoreCipherList`, unless changed using CLI options using `--tls-default-ciphers`.",
          "name": "DEFAULT_CIPHERS",
          "type": "string",
          "meta": {
            "added": [
              "v0.11.3"
            ],
            "changes": []
          },
          "desc": "The default value of the `ciphers` option of `tls.createSecureContext()`. It can be assigned any of the supported OpenSSL ciphers. Defaults to the content of `crypto.constants.defaultCoreCipherList`, unless changed using CLI options using `--tls-default-ciphers`."
        }
      ],
      "displayName": "TLS (SSL)"
    }
  ]
}