mock-tls-server 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/lib/ca.js +46 -41
- package/lib/index.js +70 -345
- package/lib/kernel.js +23 -22
- package/lib/net.js +94 -88
- package/lib/socket.js +36 -26
- package/lib/utils.js +54 -38
- package/package.json +22 -20
- package/types/ca.d.ts +9 -8
- package/types/index.d.ts +46 -763
- package/types/kernel.d.ts +6 -5
- package/types/net.d.ts +63 -46
- package/types/socket.d.ts +12 -3
- package/types/utils.d.ts +20 -13
package/types/index.d.ts
CHANGED
|
@@ -1,318 +1,40 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* All of the options that can be passed in to connect(), with text copied
|
|
4
|
-
* from the Node docs.
|
|
5
|
-
*
|
|
6
|
-
* @typedef {object} SocketConnectOpts
|
|
7
|
-
* @property {number} port Listening server port to connect to.
|
|
8
|
-
* @property {boolean} [allowHalfOpen=false] If set to false, then the socket
|
|
9
|
-
* will automatically end the writable side when the readable side ends.
|
|
10
|
-
* @property {boolean} [rejectUnauthorized=true] If not false, the server
|
|
11
|
-
* certificate is verified against the list of supplied CAs. An 'error'
|
|
12
|
-
* event is emitted if verification fails; err.code contains the OpenSSL
|
|
13
|
-
* error code.
|
|
14
|
-
* @property {PSKCallback} [pskCallback] When negotiating TLS-PSK (pre-shared
|
|
15
|
-
* keys), this function is called with optional identity hint provided by
|
|
16
|
-
* the server or null in case of TLS 1.3 where hint was removed. It will be
|
|
17
|
-
* necessary to provide a custom tls.checkServerIdentity() for the
|
|
18
|
-
* connection as the default one will try to check host name/IP of the
|
|
19
|
-
* server against the certificate but that's not applicable for PSK because
|
|
20
|
-
* there won't be a certificate present. More information can be found in
|
|
21
|
-
* the RFC 4279.
|
|
22
|
-
* @property {string[]|Buffer[]|DataView[]|Buffer|DataView} [ALPNProtocols] An
|
|
23
|
-
* array of strings, Buffers or DataViews, or a single Buffer or DataView
|
|
24
|
-
* containing the supported ALPN protocols. Buffers should have the format
|
|
25
|
-
* [len][name][len][name]... E.g. '\x08http/1.1\x08http/1.0', where the len
|
|
26
|
-
* byte is the length of the next protocol name. Passing an array is usually
|
|
27
|
-
* much simpler, e.g. ['http/1.1', 'http/1.0']. Protocols earlier in the
|
|
28
|
-
* list have higher preference than those later.
|
|
29
|
-
* @property {string} [servername] Server name for the SNI (Server Name
|
|
30
|
-
* Indication) TLS extension. It is the name of the host being connected to,
|
|
31
|
-
* and must be a host name, and not an IP address. It can be used by a
|
|
32
|
-
* multi-homed server to choose the correct certificate to present to the
|
|
33
|
-
* client, see the SNICallback option to tls.createServer().
|
|
34
|
-
* @property {tls.checkServerIdentity} [checkServerIdentity] A callback
|
|
35
|
-
* function to be used (instead of the builtin tls.checkServerIdentity()
|
|
36
|
-
* function) when checking the server's host name (or the provided
|
|
37
|
-
* servername when explicitly set) against the certificate. This should
|
|
38
|
-
* return an <Error> if verification fails. The method should return
|
|
39
|
-
* undefined if the servername and cert are verified.
|
|
40
|
-
* @property {Buffer} [session] A Buffer instance, containing TLS session.
|
|
41
|
-
* @property {number} [minDHSize=1024] Minimum size of the DH parameter in
|
|
42
|
-
* bits to accept a TLS connection. When a server offers a DH parameter with
|
|
43
|
-
* a size less than minDHSize, the TLS connection is destroyed and an error
|
|
44
|
-
* is thrown.
|
|
45
|
-
* @property {number} [highWaterMark=16 * 1024] Consistent with the readable
|
|
46
|
-
* stream highWaterMark parameter.
|
|
47
|
-
* @property {tls.SecureContext} [secureContext] TLS context object created
|
|
48
|
-
* with tls.createSecureContext(). If a secureContext is not provided, one
|
|
49
|
-
* will be created by passing the entire options object to
|
|
50
|
-
* tls.createSecureContext().
|
|
51
|
-
* @property {string[]|string|Buffer[]|Buffer} [ca] Optionally override the
|
|
52
|
-
* trusted CA certificates. Default is to trust the well-known CAs curated
|
|
53
|
-
* by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly
|
|
54
|
-
* specified using this option.
|
|
55
|
-
* @property {string[]|string|Buffer[]|Buffer} [cert] Cert chains in PEM
|
|
56
|
-
* format. One cert chain should be provided per private key. Each cert
|
|
57
|
-
* chain should consist of the PEM formatted certificate for a provided
|
|
58
|
-
* private key, followed by the PEM formatted intermediate certificates (if
|
|
59
|
-
* any), in order, and not including the root CA (the root CA must be
|
|
60
|
-
* pre-known to the peer, see ca). When providing multiple cert chains, they
|
|
61
|
-
* do not have to be in the same order as their private keys in key. If the
|
|
62
|
-
* intermediate certificates are not provided, the peer will not be able to
|
|
63
|
-
* validate the certificate, and the handshake will fail.
|
|
64
|
-
* @property {string} [sigalgs] Colon-separated list of supported signature
|
|
65
|
-
* algorithms. The list can contain digest algorithms (SHA256, MD5 etc.),
|
|
66
|
-
* public key algorithms (RSA-PSS, ECDSA etc.), combination of both
|
|
67
|
-
* ('RSA+SHA384') or TLS v1.3 scheme names (rsa_pss_pss_sha512). See OpenSSL
|
|
68
|
-
* man pages for more info.
|
|
69
|
-
* @property {string} [ciphers] Cipher suite specification, replacing the
|
|
70
|
-
* default. Cipher names are separated by colons, and must be uppercased in
|
|
71
|
-
* order for OpenSSL to accept them.
|
|
72
|
-
* @property {string} [clientCertEngine] Name of an OpenSSL engine which can
|
|
73
|
-
* provide the client certificate.
|
|
74
|
-
* @property {string|string[]|Buffer|Buffer[]} [crl] PEM formatted CRLs
|
|
75
|
-
* (Certificate Revocation Lists).
|
|
76
|
-
* @property {string|Buffer} [dhparam] Diffie-Hellman parameters, required for
|
|
77
|
-
* perfect forward secrecy. Use openssl dhparam to create the parameters.
|
|
78
|
-
* The key length must be greater than or equal to 1024 bits or else an
|
|
79
|
-
* error will be thrown. Although 1024 bits is permissible, use 2048 bits or
|
|
80
|
-
* larger for stronger security. If omitted or invalid, the parameters are
|
|
81
|
-
* silently discarded and DHE ciphers will not be available.
|
|
82
|
-
* @property {string} [ecdhCurve] A string describing a named curve or a colon
|
|
83
|
-
* separated list of curve NIDs or names, for example P-521:P-384:P-256, to
|
|
84
|
-
* use for ECDH key agreement. Set to auto to select the curve
|
|
85
|
-
* automatically. Use crypto.getCurves() to obtain a list of available curve
|
|
86
|
-
* names. On recent releases, openssl ecparam -list_curves will also display
|
|
87
|
-
* the name and description of each available elliptic curve. Default:
|
|
88
|
-
* tls.DEFAULT_ECDH_CURVE.
|
|
89
|
-
* @property {boolean} [honorCipherOrder] Attempt to use the server's cipher
|
|
90
|
-
* suite preferences instead of the client's. When true, causes
|
|
91
|
-
* SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions, see OpenSSL
|
|
92
|
-
* Options for more information.
|
|
93
|
-
* @property {string|string[]|Buffer|Buffer[]|object[]} [key] Private keys in
|
|
94
|
-
* PEM format. PEM allows the option of private keys being encrypted.
|
|
95
|
-
* Encrypted keys will be decrypted with options.passphrase. Multiple keys
|
|
96
|
-
* using different algorithms can be provided either as an array of
|
|
97
|
-
* unencrypted key strings or buffers, or an array of objects in the form
|
|
98
|
-
* {pem:string|buffer[, passphrase: string]}. The object form can only occur
|
|
99
|
-
* in an array. Passphrase is optional. Encrypted keys will be decrypted
|
|
100
|
-
* with object.passphrase if provided, or options.passphrase if it is not.
|
|
101
|
-
* @property {string} [privateKeyEngine] Name of an OpenSSL engine to get
|
|
102
|
-
* private key from. Should be used together with privateKeyIdentifier.
|
|
103
|
-
* @property {string} [privateKeyIdentifier] Identifier of a private key
|
|
104
|
-
* managed by an OpenSSL engine. Should be used together with
|
|
105
|
-
* privateKeyEngine. Should not be set together with key, because both
|
|
106
|
-
* options define a private key in different ways.
|
|
107
|
-
* @property {string} [maxVersion=tls.DEFAULT_MAX_VERSION] Optionally set the
|
|
108
|
-
* maximum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
109
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
110
|
-
* one or the other.
|
|
111
|
-
* @property {string} [minVersion=tls.DEFAULT_MIN_VERSION] Optionally set the
|
|
112
|
-
* minimum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
113
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
114
|
-
* one or the other. Avoid setting to less than TLSv1.2, but it may be
|
|
115
|
-
* required for interoperability.
|
|
116
|
-
* @property {string} [passphrase] Shared passphrase used for a single private
|
|
117
|
-
* key and/or a PFX.
|
|
118
|
-
* @property {string|string[]|Buffer|Buffer[]|object[]} [pfx] PFX or PKCS12
|
|
119
|
-
* encoded private key and certificate chain. PFX is an alternative to
|
|
120
|
-
* providing key and cert individually. PFX is usually encrypted, if it is,
|
|
121
|
-
* passphrase will be used to decrypt it.
|
|
122
|
-
* @property {number} [secureOptions] Optionally affect the OpenSSL protocol
|
|
123
|
-
* behavior, which is not usually necessary. This should be used carefully
|
|
124
|
-
* if at all! Value is a numeric bitmask of the SSL_OP_* options from
|
|
125
|
-
* OpenSSL Options.
|
|
126
|
-
* @property {string} [secureProtocol] Legacy mechanism to select the TLS
|
|
127
|
-
* protocol version to use, it does not support independent control of the
|
|
128
|
-
* minimum and maximum version, and does not support limiting the protocol
|
|
129
|
-
* to TLSv1.3. Use minVersion and maxVersion instead. The possible values
|
|
130
|
-
* are listed as SSL_METHODS, use the function names as strings. For
|
|
131
|
-
* example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method'
|
|
132
|
-
* to allow any TLS protocol version up to TLSv1.3. It is not recommended to
|
|
133
|
-
* use TLS versions less than 1.2, but it may be required for
|
|
134
|
-
* interoperability. Default: none, see minVersion.
|
|
135
|
-
* @property {string} [sessionIdContext] Opaque identifier used by servers to
|
|
136
|
-
* ensure session state is not shared between applications. Unused by
|
|
137
|
-
* clients.
|
|
138
|
-
* @property {Buffer} [ticketKeys] 48-bytes of cryptographically strong
|
|
139
|
-
* pseudorandom data. See Session Resumption for more information.
|
|
140
|
-
* @property {number} [sessionTimeout=300] The number of seconds after which a
|
|
141
|
-
* TLS session created by the server will no longer be resumable. See
|
|
142
|
-
* Session Resumption for more information.
|
|
143
|
-
*/
|
|
144
1
|
/**
|
|
145
2
|
* Create a client connection to a listening server.
|
|
146
3
|
*
|
|
147
|
-
* @param {
|
|
148
|
-
* @param {
|
|
4
|
+
* @param {tls.ConnectionOptions|number} options Port to connect to.
|
|
5
|
+
* @param {() => void} [secureListener] If specified, function is
|
|
149
6
|
* registered for the 'secure' event.
|
|
150
7
|
* @returns {tls.TLSSocket} Socket.
|
|
151
8
|
*/
|
|
152
|
-
export function connect(options:
|
|
153
|
-
declare const MockTLSServer_base: typeof import("./net.js").Server;
|
|
154
|
-
/**
|
|
155
|
-
* @callback SecureConnectionCallback
|
|
156
|
-
* @param {tls.TLSSocket} sock The server side of the socket that was connected.
|
|
157
|
-
* @returns {void}
|
|
158
|
-
*/
|
|
9
|
+
export function connect(options: tls.ConnectionOptions | number, secureListener?: (() => void) | undefined): tls.TLSSocket;
|
|
159
10
|
/**
|
|
160
|
-
* @
|
|
161
|
-
* @param {string} [hint] Optional message sent from the server to help client
|
|
162
|
-
* decide which identity to use during negotiation. Always null if TLS 1.3
|
|
163
|
-
* is used.
|
|
164
|
-
* @returns {tls.PSKCallbackNegotation|null} Or null to stop the
|
|
165
|
-
* negotiation process. PSK must be compatible with the selected cipher's
|
|
166
|
-
* digest.
|
|
11
|
+
* @typedef {(sock: tls.TLSSocket) => void} SecureConnectionCallback
|
|
167
12
|
*/
|
|
168
13
|
/**
|
|
169
|
-
* @
|
|
170
|
-
* @param {Error} [error] An error ocurred.
|
|
171
|
-
* @param {tls.SecureContext} [context] The context to use, if desired.
|
|
172
|
-
* @returns {void}
|
|
173
|
-
*/
|
|
174
|
-
/**
|
|
175
|
-
* @callback SNICallback
|
|
176
|
-
* @param {string} serverName The name passed by the client.
|
|
177
|
-
* @param {SecureContextCallback} callback Choose a security context
|
|
178
|
-
* for this connection.
|
|
179
|
-
* @returns {void}
|
|
180
|
-
*/
|
|
181
|
-
/**
|
|
182
|
-
* @typedef {object} ServerOpts
|
|
14
|
+
* @typedef {object} LocalOptions
|
|
183
15
|
* @property {CertificateAuthority} [authority] A CA instance to use. If you
|
|
184
16
|
* are creating lots of servers, create one CA to pass into each of them, so
|
|
185
17
|
* that certs don't need to be created from scratch for each.
|
|
186
18
|
* @property {SecureConnectionCallback} [secureConnectionListener] Installed
|
|
187
19
|
* as a listener for the 'secureConnection' event.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* @
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* @property {boolean} rejectUnauthorized See tls.createServer().
|
|
202
|
-
* @property {string[]|Buffer[]|DataView[]|Buffer|DataView} [ALPNProtocols] An
|
|
203
|
-
* array of strings, Buffers or DataViews, or a single Buffer or DataView
|
|
204
|
-
* containing the supported ALPN protocols. Buffers should have the format
|
|
205
|
-
* [len][name][len][name]... E.g. '\x08http/1.1\x08http/1.0', where the len
|
|
206
|
-
* byte is the length of the next protocol name. Passing an array is usually
|
|
207
|
-
* much simpler, e.g. ['http/1.1', 'http/1.0']. Protocols earlier in the
|
|
208
|
-
* list have higher preference than those later.
|
|
209
|
-
* @property {SNICallback} SNICallback See tls.createServer().
|
|
210
|
-
* @property {Buffer} [session] A Buffer instance, containing TLS session.
|
|
211
|
-
* @property {boolean} requestOCSP If true, specifies that the OCSP status
|
|
212
|
-
* request extension will be added to the client hello and an 'OCSPResponse'
|
|
213
|
-
* event will be emitted on the socket before establishing a secure
|
|
214
|
-
* communication.
|
|
215
|
-
* @property {tls.SecureContext} [secureContext] TLS context object created
|
|
216
|
-
* with tls.createSecureContext(). If a secureContext is not provided, one
|
|
217
|
-
* will be created by passing the entire options object to
|
|
218
|
-
* tls.createSecureContext().
|
|
219
|
-
* @property {string[]|string|Buffer[]|Buffer} [ca] Optionally override the
|
|
220
|
-
* trusted CA certificates. Default is to trust the well-known CAs curated
|
|
221
|
-
* by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly
|
|
222
|
-
* specified using this option.
|
|
223
|
-
* @property {string[]|string|Buffer[]|Buffer} [cert] Cert chains in PEM
|
|
224
|
-
* format. One cert chain should be provided per private key. Each cert
|
|
225
|
-
* chain should consist of the PEM formatted certificate for a provided
|
|
226
|
-
* private key, followed by the PEM formatted intermediate certificates (if
|
|
227
|
-
* any), in order, and not including the root CA (the root CA must be
|
|
228
|
-
* pre-known to the peer, see ca). When providing multiple cert chains, they
|
|
229
|
-
* do not have to be in the same order as their private keys in key. If the
|
|
230
|
-
* intermediate certificates are not provided, the peer will not be able to
|
|
231
|
-
* validate the certificate, and the handshake will fail.
|
|
232
|
-
* @property {string} [sigalgs] Colon-separated list of supported signature
|
|
233
|
-
* algorithms. The list can contain digest algorithms (SHA256, MD5 etc.),
|
|
234
|
-
* public key algorithms (RSA-PSS, ECDSA etc.), combination of both
|
|
235
|
-
* ('RSA+SHA384') or TLS v1.3 scheme names (rsa_pss_pss_sha512). See OpenSSL
|
|
236
|
-
* man pages for more info.
|
|
237
|
-
* @property {string} [ciphers] Cipher suite specification, replacing the
|
|
238
|
-
* default. Cipher names are separated by colons, and must be uppercased in
|
|
239
|
-
* order for OpenSSL to accept them.
|
|
240
|
-
* @property {string} [clientCertEngine] Name of an OpenSSL engine which can
|
|
241
|
-
* provide the client certificate.
|
|
242
|
-
* @property {string|string[]|Buffer|Buffer[]} [crl] PEM formatted CRLs
|
|
243
|
-
* (Certificate Revocation Lists).
|
|
244
|
-
* @property {string|Buffer} [dhparam] Diffie-Hellman parameters, required for
|
|
245
|
-
* perfect forward secrecy. Use openssl dhparam to create the parameters.
|
|
246
|
-
* The key length must be greater than or equal to 1024 bits or else an
|
|
247
|
-
* error will be thrown. Although 1024 bits is permissible, use 2048 bits or
|
|
248
|
-
* larger for stronger security. If omitted or invalid, the parameters are
|
|
249
|
-
* silently discarded and DHE ciphers will not be available.
|
|
250
|
-
* @property {string} [ecdhCurve] A string describing a named curve or a colon
|
|
251
|
-
* separated list of curve NIDs or names, for example P-521:P-384:P-256, to
|
|
252
|
-
* use for ECDH key agreement. Set to auto to select the curve
|
|
253
|
-
* automatically. Use crypto.getCurves() to obtain a list of available curve
|
|
254
|
-
* names. On recent releases, openssl ecparam -list_curves will also display
|
|
255
|
-
* the name and description of each available elliptic curve. Default:
|
|
256
|
-
* tls.DEFAULT_ECDH_CURVE.
|
|
257
|
-
* @property {boolean} [honorCipherOrder] Attempt to use the server's cipher
|
|
258
|
-
* suite preferences instead of the client's. When true, causes
|
|
259
|
-
* SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions, see OpenSSL
|
|
260
|
-
* Options for more information.
|
|
261
|
-
* @property {string|string[]|Buffer|Buffer[]|object[]} [key] Private keys in
|
|
262
|
-
* PEM format. PEM allows the option of private keys being encrypted.
|
|
263
|
-
* Encrypted keys will be decrypted with options.passphrase. Multiple keys
|
|
264
|
-
* using different algorithms can be provided either as an array of
|
|
265
|
-
* unencrypted key strings or buffers, or an array of objects in the form
|
|
266
|
-
* {pem:string|buffer[, passphrase: string]}. The object form can only occur
|
|
267
|
-
* in an array. Passphrase is optional. Encrypted keys will be decrypted
|
|
268
|
-
* with object.passphrase if provided, or options.passphrase if it is not.
|
|
269
|
-
* @property {string} [privateKeyEngine] Name of an OpenSSL engine to get
|
|
270
|
-
* private key from. Should be used together with privateKeyIdentifier.
|
|
271
|
-
* @property {string} [privateKeyIdentifier] Identifier of a private key
|
|
272
|
-
* managed by an OpenSSL engine. Should be used together with
|
|
273
|
-
* privateKeyEngine. Should not be set together with key, because both
|
|
274
|
-
* options define a private key in different ways.
|
|
275
|
-
* @property {string} [maxVersion=tls.DEFAULT_MAX_VERSION] Optionally set the
|
|
276
|
-
* maximum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
277
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
278
|
-
* one or the other.
|
|
279
|
-
* @property {string} [minVersion=tls.DEFAULT_MIN_VERSION] Optionally set the
|
|
280
|
-
* minimum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
281
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
282
|
-
* one or the other. Avoid setting to less than TLSv1.2, but it may be
|
|
283
|
-
* required for interoperability.
|
|
284
|
-
* @property {string} [passphrase] Shared passphrase used for a single private
|
|
285
|
-
* key and/or a PFX.
|
|
286
|
-
* @property {string|string[]|Buffer|Buffer[]|object[]} [pfx] PFX or PKCS12
|
|
287
|
-
* encoded private key and certificate chain. PFX is an alternative to
|
|
288
|
-
* providing key and cert individually. PFX is usually encrypted, if it is,
|
|
289
|
-
* passphrase will be used to decrypt it.
|
|
290
|
-
* @property {number} [secureOptions] Optionally affect the OpenSSL protocol
|
|
291
|
-
* behavior, which is not usually necessary. This should be used carefully
|
|
292
|
-
* if at all! Value is a numeric bitmask of the SSL_OP_* options from
|
|
293
|
-
* OpenSSL Options.
|
|
294
|
-
* @property {string} [secureProtocol] Legacy mechanism to select the TLS
|
|
295
|
-
* protocol version to use, it does not support independent control of the
|
|
296
|
-
* minimum and maximum version, and does not support limiting the protocol
|
|
297
|
-
* to TLSv1.3. Use minVersion and maxVersion instead. The possible values
|
|
298
|
-
* are listed as SSL_METHODS, use the function names as strings. For
|
|
299
|
-
* example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method'
|
|
300
|
-
* to allow any TLS protocol version up to TLSv1.3. It is not recommended to
|
|
301
|
-
* use TLS versions less than 1.2, but it may be required for
|
|
302
|
-
* interoperability. Default: none, see minVersion.
|
|
303
|
-
* @property {string} [sessionIdContext] Opaque identifier used by servers to
|
|
304
|
-
* ensure session state is not shared between applications. Unused by
|
|
305
|
-
* clients.
|
|
306
|
-
* @property {Buffer} [ticketKeys] 48-bytes of cryptographically strong
|
|
307
|
-
* pseudorandom data. See Session Resumption for more information.
|
|
308
|
-
* @property {number} [sessionTimeout=300] The number of seconds after which a
|
|
309
|
-
* TLS session created by the server will no longer be resumable. See
|
|
310
|
-
* Session Resumption for more information.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {LocalOptions &
|
|
23
|
+
* tls.TLSSocketOptions &
|
|
24
|
+
* import('./ca.js').CertOpts &
|
|
25
|
+
* import('./net.js').ServerOpts
|
|
26
|
+
* } ServerOpts
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {object} ListenOptions
|
|
30
|
+
* @property {number} port The port to listen on.
|
|
31
|
+
* @property {SecureConnectionCallback} secureConnectionListener If it exists,
|
|
32
|
+
* installed as a listener for the 'secureConnection' event.
|
|
311
33
|
*/
|
|
312
34
|
/**
|
|
313
35
|
* A TLS server that mocks the network, but all of the crypto code is real.
|
|
314
36
|
*/
|
|
315
|
-
export class MockTLSServer extends
|
|
37
|
+
export class MockTLSServer extends net.Server {
|
|
316
38
|
/**
|
|
317
39
|
* Create a MockTLSServer instance.
|
|
318
40
|
*
|
|
@@ -320,493 +42,54 @@ export class MockTLSServer extends MockTLSServer_base {
|
|
|
320
42
|
* @param {SecureConnectionCallback} [secureConnectionListener] Installed as
|
|
321
43
|
* a listener for the 'secureConnection' event.
|
|
322
44
|
*/
|
|
323
|
-
constructor(options?: ServerOpts |
|
|
45
|
+
constructor(options?: SecureConnectionCallback | ServerOpts | undefined, secureConnectionListener?: SecureConnectionCallback | undefined);
|
|
324
46
|
cert: any;
|
|
325
47
|
ca: any;
|
|
48
|
+
/**
|
|
49
|
+
* Listen for incoming connections. Whenever `connect` is called on this
|
|
50
|
+
* server's port, create a mock socket wrapped in a TLSSocket.
|
|
51
|
+
*
|
|
52
|
+
* @param {number|ListenOptions} [options] Port number or options object.
|
|
53
|
+
* @param {Function} [secureConnectionListener] If it exists, installed as
|
|
54
|
+
* a listener for the 'secureConnection' event.
|
|
55
|
+
* @returns {MockTLSServer} This.
|
|
56
|
+
*/
|
|
57
|
+
listen(options?: number | ListenOptions | undefined, secureConnectionListener?: Function | undefined): MockTLSServer;
|
|
58
|
+
#private;
|
|
326
59
|
}
|
|
327
|
-
export const plainConnect: typeof
|
|
60
|
+
export const plainConnect: typeof net.connect;
|
|
328
61
|
declare namespace _default {
|
|
329
62
|
export { MockTLSServer };
|
|
330
63
|
export { connect };
|
|
331
64
|
export { plainConnect };
|
|
332
65
|
}
|
|
333
66
|
export default _default;
|
|
334
|
-
/**
|
|
335
|
-
* All of the options that can be passed in to connect(), with text copied
|
|
336
|
-
* from the Node docs.
|
|
337
|
-
*/
|
|
338
|
-
export type SocketConnectOpts = {
|
|
339
|
-
/**
|
|
340
|
-
* Listening server port to connect to.
|
|
341
|
-
*/
|
|
342
|
-
port: number;
|
|
343
|
-
/**
|
|
344
|
-
* If set to false, then the socket
|
|
345
|
-
* will automatically end the writable side when the readable side ends.
|
|
346
|
-
*/
|
|
347
|
-
allowHalfOpen?: boolean;
|
|
348
|
-
/**
|
|
349
|
-
* If not false, the server
|
|
350
|
-
* certificate is verified against the list of supplied CAs. An 'error'
|
|
351
|
-
* event is emitted if verification fails; err.code contains the OpenSSL
|
|
352
|
-
* error code.
|
|
353
|
-
*/
|
|
354
|
-
rejectUnauthorized?: boolean;
|
|
355
|
-
/**
|
|
356
|
-
* When negotiating TLS-PSK (pre-shared
|
|
357
|
-
* keys), this function is called with optional identity hint provided by
|
|
358
|
-
* the server or null in case of TLS 1.3 where hint was removed. It will be
|
|
359
|
-
* necessary to provide a custom tls.checkServerIdentity() for the
|
|
360
|
-
* connection as the default one will try to check host name/IP of the
|
|
361
|
-
* server against the certificate but that's not applicable for PSK because
|
|
362
|
-
* there won't be a certificate present. More information can be found in
|
|
363
|
-
* the RFC 4279.
|
|
364
|
-
*/
|
|
365
|
-
pskCallback?: PSKCallback;
|
|
366
|
-
/**
|
|
367
|
-
* An
|
|
368
|
-
* array of strings, Buffers or DataViews, or a single Buffer or DataView
|
|
369
|
-
* containing the supported ALPN protocols. Buffers should have the format
|
|
370
|
-
* [len][name][len][name]... E.g. '\x08http/1.1\x08http/1.0', where the len
|
|
371
|
-
* byte is the length of the next protocol name. Passing an array is usually
|
|
372
|
-
* much simpler, e.g. ['http/1.1', 'http/1.0']. Protocols earlier in the
|
|
373
|
-
* list have higher preference than those later.
|
|
374
|
-
*/
|
|
375
|
-
ALPNProtocols?: string[] | Buffer[] | DataView[] | Buffer | DataView;
|
|
376
|
-
/**
|
|
377
|
-
* Server name for the SNI (Server Name
|
|
378
|
-
* Indication) TLS extension. It is the name of the host being connected to,
|
|
379
|
-
* and must be a host name, and not an IP address. It can be used by a
|
|
380
|
-
* multi-homed server to choose the correct certificate to present to the
|
|
381
|
-
* client, see the SNICallback option to tls.createServer().
|
|
382
|
-
*/
|
|
383
|
-
servername?: string;
|
|
384
|
-
/**
|
|
385
|
-
* A callback
|
|
386
|
-
* function to be used (instead of the builtin tls.checkServerIdentity()
|
|
387
|
-
* function) when checking the server's host name (or the provided
|
|
388
|
-
* servername when explicitly set) against the certificate. This should
|
|
389
|
-
* return an <Error> if verification fails. The method should return
|
|
390
|
-
* undefined if the servername and cert are verified.
|
|
391
|
-
*/
|
|
392
|
-
checkServerIdentity?: typeof tls.checkServerIdentity;
|
|
393
|
-
/**
|
|
394
|
-
* A Buffer instance, containing TLS session.
|
|
395
|
-
*/
|
|
396
|
-
session?: Buffer;
|
|
397
|
-
/**
|
|
398
|
-
* Minimum size of the DH parameter in
|
|
399
|
-
* bits to accept a TLS connection. When a server offers a DH parameter with
|
|
400
|
-
* a size less than minDHSize, the TLS connection is destroyed and an error
|
|
401
|
-
* is thrown.
|
|
402
|
-
*/
|
|
403
|
-
minDHSize?: number;
|
|
404
|
-
/**
|
|
405
|
-
* Consistent with the readable
|
|
406
|
-
* stream highWaterMark parameter.
|
|
407
|
-
*/
|
|
408
|
-
highWaterMark?: number;
|
|
409
|
-
/**
|
|
410
|
-
* TLS context object created
|
|
411
|
-
* with tls.createSecureContext(). If a secureContext is not provided, one
|
|
412
|
-
* will be created by passing the entire options object to
|
|
413
|
-
* tls.createSecureContext().
|
|
414
|
-
*/
|
|
415
|
-
secureContext?: tls.SecureContext;
|
|
416
|
-
/**
|
|
417
|
-
* Optionally override the
|
|
418
|
-
* trusted CA certificates. Default is to trust the well-known CAs curated
|
|
419
|
-
* by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly
|
|
420
|
-
* specified using this option.
|
|
421
|
-
*/
|
|
422
|
-
ca?: string[] | string | Buffer[] | Buffer;
|
|
423
|
-
/**
|
|
424
|
-
* Cert chains in PEM
|
|
425
|
-
* format. One cert chain should be provided per private key. Each cert
|
|
426
|
-
* chain should consist of the PEM formatted certificate for a provided
|
|
427
|
-
* private key, followed by the PEM formatted intermediate certificates (if
|
|
428
|
-
* any), in order, and not including the root CA (the root CA must be
|
|
429
|
-
* pre-known to the peer, see ca). When providing multiple cert chains, they
|
|
430
|
-
* do not have to be in the same order as their private keys in key. If the
|
|
431
|
-
* intermediate certificates are not provided, the peer will not be able to
|
|
432
|
-
* validate the certificate, and the handshake will fail.
|
|
433
|
-
*/
|
|
434
|
-
cert?: string[] | string | Buffer[] | Buffer;
|
|
435
|
-
/**
|
|
436
|
-
* Colon-separated list of supported signature
|
|
437
|
-
* algorithms. The list can contain digest algorithms (SHA256, MD5 etc.),
|
|
438
|
-
* public key algorithms (RSA-PSS, ECDSA etc.), combination of both
|
|
439
|
-
* ('RSA+SHA384') or TLS v1.3 scheme names (rsa_pss_pss_sha512). See OpenSSL
|
|
440
|
-
* man pages for more info.
|
|
441
|
-
*/
|
|
442
|
-
sigalgs?: string;
|
|
443
|
-
/**
|
|
444
|
-
* Cipher suite specification, replacing the
|
|
445
|
-
* default. Cipher names are separated by colons, and must be uppercased in
|
|
446
|
-
* order for OpenSSL to accept them.
|
|
447
|
-
*/
|
|
448
|
-
ciphers?: string;
|
|
449
|
-
/**
|
|
450
|
-
* Name of an OpenSSL engine which can
|
|
451
|
-
* provide the client certificate.
|
|
452
|
-
*/
|
|
453
|
-
clientCertEngine?: string;
|
|
454
|
-
/**
|
|
455
|
-
* PEM formatted CRLs
|
|
456
|
-
* (Certificate Revocation Lists).
|
|
457
|
-
*/
|
|
458
|
-
crl?: string | string[] | Buffer | Buffer[];
|
|
459
|
-
/**
|
|
460
|
-
* Diffie-Hellman parameters, required for
|
|
461
|
-
* perfect forward secrecy. Use openssl dhparam to create the parameters.
|
|
462
|
-
* The key length must be greater than or equal to 1024 bits or else an
|
|
463
|
-
* error will be thrown. Although 1024 bits is permissible, use 2048 bits or
|
|
464
|
-
* larger for stronger security. If omitted or invalid, the parameters are
|
|
465
|
-
* silently discarded and DHE ciphers will not be available.
|
|
466
|
-
*/
|
|
467
|
-
dhparam?: string | Buffer;
|
|
468
|
-
/**
|
|
469
|
-
* A string describing a named curve or a colon
|
|
470
|
-
* separated list of curve NIDs or names, for example P-521:P-384:P-256, to
|
|
471
|
-
* use for ECDH key agreement. Set to auto to select the curve
|
|
472
|
-
* automatically. Use crypto.getCurves() to obtain a list of available curve
|
|
473
|
-
* names. On recent releases, openssl ecparam -list_curves will also display
|
|
474
|
-
* the name and description of each available elliptic curve. Default:
|
|
475
|
-
* tls.DEFAULT_ECDH_CURVE.
|
|
476
|
-
*/
|
|
477
|
-
ecdhCurve?: string;
|
|
478
|
-
/**
|
|
479
|
-
* Attempt to use the server's cipher
|
|
480
|
-
* suite preferences instead of the client's. When true, causes
|
|
481
|
-
* SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions, see OpenSSL
|
|
482
|
-
* Options for more information.
|
|
483
|
-
*/
|
|
484
|
-
honorCipherOrder?: boolean;
|
|
485
|
-
/**
|
|
486
|
-
* Private keys in
|
|
487
|
-
* PEM format. PEM allows the option of private keys being encrypted.
|
|
488
|
-
* Encrypted keys will be decrypted with options.passphrase. Multiple keys
|
|
489
|
-
* using different algorithms can be provided either as an array of
|
|
490
|
-
* unencrypted key strings or buffers, or an array of objects in the form
|
|
491
|
-
* {pem:string|buffer[, passphrase: string]}. The object form can only occur
|
|
492
|
-
* in an array. Passphrase is optional. Encrypted keys will be decrypted
|
|
493
|
-
* with object.passphrase if provided, or options.passphrase if it is not.
|
|
494
|
-
*/
|
|
495
|
-
key?: string | string[] | Buffer | Buffer[] | object[];
|
|
496
|
-
/**
|
|
497
|
-
* Name of an OpenSSL engine to get
|
|
498
|
-
* private key from. Should be used together with privateKeyIdentifier.
|
|
499
|
-
*/
|
|
500
|
-
privateKeyEngine?: string;
|
|
501
|
-
/**
|
|
502
|
-
* Identifier of a private key
|
|
503
|
-
* managed by an OpenSSL engine. Should be used together with
|
|
504
|
-
* privateKeyEngine. Should not be set together with key, because both
|
|
505
|
-
* options define a private key in different ways.
|
|
506
|
-
*/
|
|
507
|
-
privateKeyIdentifier?: string;
|
|
508
|
-
/**
|
|
509
|
-
* Optionally set the
|
|
510
|
-
* maximum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
511
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
512
|
-
* one or the other.
|
|
513
|
-
*/
|
|
514
|
-
maxVersion?: string;
|
|
515
|
-
/**
|
|
516
|
-
* Optionally set the
|
|
517
|
-
* minimum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
518
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
519
|
-
* one or the other. Avoid setting to less than TLSv1.2, but it may be
|
|
520
|
-
* required for interoperability.
|
|
521
|
-
*/
|
|
522
|
-
minVersion?: string;
|
|
523
|
-
/**
|
|
524
|
-
* Shared passphrase used for a single private
|
|
525
|
-
* key and/or a PFX.
|
|
526
|
-
*/
|
|
527
|
-
passphrase?: string;
|
|
528
|
-
/**
|
|
529
|
-
* PFX or PKCS12
|
|
530
|
-
* encoded private key and certificate chain. PFX is an alternative to
|
|
531
|
-
* providing key and cert individually. PFX is usually encrypted, if it is,
|
|
532
|
-
* passphrase will be used to decrypt it.
|
|
533
|
-
*/
|
|
534
|
-
pfx?: string | string[] | Buffer | Buffer[] | object[];
|
|
535
|
-
/**
|
|
536
|
-
* Optionally affect the OpenSSL protocol
|
|
537
|
-
* behavior, which is not usually necessary. This should be used carefully
|
|
538
|
-
* if at all! Value is a numeric bitmask of the SSL_OP_* options from
|
|
539
|
-
* OpenSSL Options.
|
|
540
|
-
*/
|
|
541
|
-
secureOptions?: number;
|
|
542
|
-
/**
|
|
543
|
-
* Legacy mechanism to select the TLS
|
|
544
|
-
* protocol version to use, it does not support independent control of the
|
|
545
|
-
* minimum and maximum version, and does not support limiting the protocol
|
|
546
|
-
* to TLSv1.3. Use minVersion and maxVersion instead. The possible values
|
|
547
|
-
* are listed as SSL_METHODS, use the function names as strings. For
|
|
548
|
-
* example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method'
|
|
549
|
-
* to allow any TLS protocol version up to TLSv1.3. It is not recommended to
|
|
550
|
-
* use TLS versions less than 1.2, but it may be required for
|
|
551
|
-
* interoperability. Default: none, see minVersion.
|
|
552
|
-
*/
|
|
553
|
-
secureProtocol?: string;
|
|
554
|
-
/**
|
|
555
|
-
* Opaque identifier used by servers to
|
|
556
|
-
* ensure session state is not shared between applications. Unused by
|
|
557
|
-
* clients.
|
|
558
|
-
*/
|
|
559
|
-
sessionIdContext?: string;
|
|
560
|
-
/**
|
|
561
|
-
* 48-bytes of cryptographically strong
|
|
562
|
-
* pseudorandom data. See Session Resumption for more information.
|
|
563
|
-
*/
|
|
564
|
-
ticketKeys?: Buffer;
|
|
565
|
-
/**
|
|
566
|
-
* The number of seconds after which a
|
|
567
|
-
* TLS session created by the server will no longer be resumable. See
|
|
568
|
-
* Session Resumption for more information.
|
|
569
|
-
*/
|
|
570
|
-
sessionTimeout?: number;
|
|
571
|
-
};
|
|
572
67
|
export type SecureConnectionCallback = (sock: tls.TLSSocket) => void;
|
|
573
|
-
export type
|
|
574
|
-
export type SecureContextCallback = (error?: Error, context?: tls.SecureContext) => void;
|
|
575
|
-
export type SNICallback = (serverName: string, callback: SecureContextCallback) => void;
|
|
576
|
-
export type ServerOpts = {
|
|
68
|
+
export type LocalOptions = {
|
|
577
69
|
/**
|
|
578
70
|
* A CA instance to use. If you
|
|
579
71
|
* are creating lots of servers, create one CA to pass into each of them, so
|
|
580
72
|
* that certs don't need to be created from scratch for each.
|
|
581
73
|
*/
|
|
582
|
-
authority?: CertificateAuthority;
|
|
74
|
+
authority?: CertificateAuthority | undefined;
|
|
583
75
|
/**
|
|
584
76
|
* Installed
|
|
585
77
|
* as a listener for the 'secureConnection' event.
|
|
586
78
|
*/
|
|
587
|
-
secureConnectionListener?: SecureConnectionCallback;
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
*/
|
|
592
|
-
notafter?: Date;
|
|
593
|
-
/**
|
|
594
|
-
* Certificate not valid before this
|
|
595
|
-
* date.
|
|
596
|
-
*/
|
|
597
|
-
notbefore?: Date;
|
|
598
|
-
/**
|
|
599
|
-
* Subject Distinguished Name (DN).
|
|
600
|
-
*/
|
|
601
|
-
subject?: string;
|
|
602
|
-
/**
|
|
603
|
-
* DNS Subject Alternative Names
|
|
604
|
-
* for the cert. Ignored for the CA cert.
|
|
605
|
-
*/
|
|
606
|
-
names?: string[];
|
|
607
|
-
/**
|
|
608
|
-
* If set to false, then the socket
|
|
609
|
-
* will automatically end the writable side when the readable side ends.
|
|
610
|
-
*/
|
|
611
|
-
allowHalfOpen?: boolean;
|
|
612
|
-
/**
|
|
613
|
-
* Whether to authenticate the remote peer by
|
|
614
|
-
* requesting a certificate. Clients always request a server certificate.
|
|
615
|
-
* Servers (isServer is true) may set requestCert to true to request a
|
|
616
|
-
* client certificate.
|
|
617
|
-
*/
|
|
618
|
-
requestCert: boolean;
|
|
619
|
-
/**
|
|
620
|
-
* See tls.createServer().
|
|
621
|
-
*/
|
|
622
|
-
rejectUnauthorized: boolean;
|
|
623
|
-
/**
|
|
624
|
-
* An
|
|
625
|
-
* array of strings, Buffers or DataViews, or a single Buffer or DataView
|
|
626
|
-
* containing the supported ALPN protocols. Buffers should have the format
|
|
627
|
-
* [len][name][len][name]... E.g. '\x08http/1.1\x08http/1.0', where the len
|
|
628
|
-
* byte is the length of the next protocol name. Passing an array is usually
|
|
629
|
-
* much simpler, e.g. ['http/1.1', 'http/1.0']. Protocols earlier in the
|
|
630
|
-
* list have higher preference than those later.
|
|
631
|
-
*/
|
|
632
|
-
ALPNProtocols?: string[] | Buffer[] | DataView[] | Buffer | DataView;
|
|
633
|
-
/**
|
|
634
|
-
* See tls.createServer().
|
|
635
|
-
*/
|
|
636
|
-
SNICallback: SNICallback;
|
|
637
|
-
/**
|
|
638
|
-
* A Buffer instance, containing TLS session.
|
|
639
|
-
*/
|
|
640
|
-
session?: Buffer;
|
|
641
|
-
/**
|
|
642
|
-
* If true, specifies that the OCSP status
|
|
643
|
-
* request extension will be added to the client hello and an 'OCSPResponse'
|
|
644
|
-
* event will be emitted on the socket before establishing a secure
|
|
645
|
-
* communication.
|
|
646
|
-
*/
|
|
647
|
-
requestOCSP: boolean;
|
|
648
|
-
/**
|
|
649
|
-
* TLS context object created
|
|
650
|
-
* with tls.createSecureContext(). If a secureContext is not provided, one
|
|
651
|
-
* will be created by passing the entire options object to
|
|
652
|
-
* tls.createSecureContext().
|
|
653
|
-
*/
|
|
654
|
-
secureContext?: tls.SecureContext;
|
|
655
|
-
/**
|
|
656
|
-
* Optionally override the
|
|
657
|
-
* trusted CA certificates. Default is to trust the well-known CAs curated
|
|
658
|
-
* by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly
|
|
659
|
-
* specified using this option.
|
|
660
|
-
*/
|
|
661
|
-
ca?: string[] | string | Buffer[] | Buffer;
|
|
662
|
-
/**
|
|
663
|
-
* Cert chains in PEM
|
|
664
|
-
* format. One cert chain should be provided per private key. Each cert
|
|
665
|
-
* chain should consist of the PEM formatted certificate for a provided
|
|
666
|
-
* private key, followed by the PEM formatted intermediate certificates (if
|
|
667
|
-
* any), in order, and not including the root CA (the root CA must be
|
|
668
|
-
* pre-known to the peer, see ca). When providing multiple cert chains, they
|
|
669
|
-
* do not have to be in the same order as their private keys in key. If the
|
|
670
|
-
* intermediate certificates are not provided, the peer will not be able to
|
|
671
|
-
* validate the certificate, and the handshake will fail.
|
|
672
|
-
*/
|
|
673
|
-
cert?: string[] | string | Buffer[] | Buffer;
|
|
674
|
-
/**
|
|
675
|
-
* Colon-separated list of supported signature
|
|
676
|
-
* algorithms. The list can contain digest algorithms (SHA256, MD5 etc.),
|
|
677
|
-
* public key algorithms (RSA-PSS, ECDSA etc.), combination of both
|
|
678
|
-
* ('RSA+SHA384') or TLS v1.3 scheme names (rsa_pss_pss_sha512). See OpenSSL
|
|
679
|
-
* man pages for more info.
|
|
680
|
-
*/
|
|
681
|
-
sigalgs?: string;
|
|
682
|
-
/**
|
|
683
|
-
* Cipher suite specification, replacing the
|
|
684
|
-
* default. Cipher names are separated by colons, and must be uppercased in
|
|
685
|
-
* order for OpenSSL to accept them.
|
|
686
|
-
*/
|
|
687
|
-
ciphers?: string;
|
|
688
|
-
/**
|
|
689
|
-
* Name of an OpenSSL engine which can
|
|
690
|
-
* provide the client certificate.
|
|
691
|
-
*/
|
|
692
|
-
clientCertEngine?: string;
|
|
693
|
-
/**
|
|
694
|
-
* PEM formatted CRLs
|
|
695
|
-
* (Certificate Revocation Lists).
|
|
696
|
-
*/
|
|
697
|
-
crl?: string | string[] | Buffer | Buffer[];
|
|
698
|
-
/**
|
|
699
|
-
* Diffie-Hellman parameters, required for
|
|
700
|
-
* perfect forward secrecy. Use openssl dhparam to create the parameters.
|
|
701
|
-
* The key length must be greater than or equal to 1024 bits or else an
|
|
702
|
-
* error will be thrown. Although 1024 bits is permissible, use 2048 bits or
|
|
703
|
-
* larger for stronger security. If omitted or invalid, the parameters are
|
|
704
|
-
* silently discarded and DHE ciphers will not be available.
|
|
705
|
-
*/
|
|
706
|
-
dhparam?: string | Buffer;
|
|
707
|
-
/**
|
|
708
|
-
* A string describing a named curve or a colon
|
|
709
|
-
* separated list of curve NIDs or names, for example P-521:P-384:P-256, to
|
|
710
|
-
* use for ECDH key agreement. Set to auto to select the curve
|
|
711
|
-
* automatically. Use crypto.getCurves() to obtain a list of available curve
|
|
712
|
-
* names. On recent releases, openssl ecparam -list_curves will also display
|
|
713
|
-
* the name and description of each available elliptic curve. Default:
|
|
714
|
-
* tls.DEFAULT_ECDH_CURVE.
|
|
715
|
-
*/
|
|
716
|
-
ecdhCurve?: string;
|
|
717
|
-
/**
|
|
718
|
-
* Attempt to use the server's cipher
|
|
719
|
-
* suite preferences instead of the client's. When true, causes
|
|
720
|
-
* SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions, see OpenSSL
|
|
721
|
-
* Options for more information.
|
|
722
|
-
*/
|
|
723
|
-
honorCipherOrder?: boolean;
|
|
724
|
-
/**
|
|
725
|
-
* Private keys in
|
|
726
|
-
* PEM format. PEM allows the option of private keys being encrypted.
|
|
727
|
-
* Encrypted keys will be decrypted with options.passphrase. Multiple keys
|
|
728
|
-
* using different algorithms can be provided either as an array of
|
|
729
|
-
* unencrypted key strings or buffers, or an array of objects in the form
|
|
730
|
-
* {pem:string|buffer[, passphrase: string]}. The object form can only occur
|
|
731
|
-
* in an array. Passphrase is optional. Encrypted keys will be decrypted
|
|
732
|
-
* with object.passphrase if provided, or options.passphrase if it is not.
|
|
733
|
-
*/
|
|
734
|
-
key?: string | string[] | Buffer | Buffer[] | object[];
|
|
735
|
-
/**
|
|
736
|
-
* Name of an OpenSSL engine to get
|
|
737
|
-
* private key from. Should be used together with privateKeyIdentifier.
|
|
738
|
-
*/
|
|
739
|
-
privateKeyEngine?: string;
|
|
740
|
-
/**
|
|
741
|
-
* Identifier of a private key
|
|
742
|
-
* managed by an OpenSSL engine. Should be used together with
|
|
743
|
-
* privateKeyEngine. Should not be set together with key, because both
|
|
744
|
-
* options define a private key in different ways.
|
|
745
|
-
*/
|
|
746
|
-
privateKeyIdentifier?: string;
|
|
747
|
-
/**
|
|
748
|
-
* Optionally set the
|
|
749
|
-
* maximum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
750
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
751
|
-
* one or the other.
|
|
752
|
-
*/
|
|
753
|
-
maxVersion?: string;
|
|
754
|
-
/**
|
|
755
|
-
* Optionally set the
|
|
756
|
-
* minimum TLS version to allow. One of 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or
|
|
757
|
-
* 'TLSv1'. Cannot be specified along with the secureProtocol option; use
|
|
758
|
-
* one or the other. Avoid setting to less than TLSv1.2, but it may be
|
|
759
|
-
* required for interoperability.
|
|
760
|
-
*/
|
|
761
|
-
minVersion?: string;
|
|
762
|
-
/**
|
|
763
|
-
* Shared passphrase used for a single private
|
|
764
|
-
* key and/or a PFX.
|
|
765
|
-
*/
|
|
766
|
-
passphrase?: string;
|
|
767
|
-
/**
|
|
768
|
-
* PFX or PKCS12
|
|
769
|
-
* encoded private key and certificate chain. PFX is an alternative to
|
|
770
|
-
* providing key and cert individually. PFX is usually encrypted, if it is,
|
|
771
|
-
* passphrase will be used to decrypt it.
|
|
772
|
-
*/
|
|
773
|
-
pfx?: string | string[] | Buffer | Buffer[] | object[];
|
|
774
|
-
/**
|
|
775
|
-
* Optionally affect the OpenSSL protocol
|
|
776
|
-
* behavior, which is not usually necessary. This should be used carefully
|
|
777
|
-
* if at all! Value is a numeric bitmask of the SSL_OP_* options from
|
|
778
|
-
* OpenSSL Options.
|
|
779
|
-
*/
|
|
780
|
-
secureOptions?: number;
|
|
781
|
-
/**
|
|
782
|
-
* Legacy mechanism to select the TLS
|
|
783
|
-
* protocol version to use, it does not support independent control of the
|
|
784
|
-
* minimum and maximum version, and does not support limiting the protocol
|
|
785
|
-
* to TLSv1.3. Use minVersion and maxVersion instead. The possible values
|
|
786
|
-
* are listed as SSL_METHODS, use the function names as strings. For
|
|
787
|
-
* example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method'
|
|
788
|
-
* to allow any TLS protocol version up to TLSv1.3. It is not recommended to
|
|
789
|
-
* use TLS versions less than 1.2, but it may be required for
|
|
790
|
-
* interoperability. Default: none, see minVersion.
|
|
791
|
-
*/
|
|
792
|
-
secureProtocol?: string;
|
|
793
|
-
/**
|
|
794
|
-
* Opaque identifier used by servers to
|
|
795
|
-
* ensure session state is not shared between applications. Unused by
|
|
796
|
-
* clients.
|
|
797
|
-
*/
|
|
798
|
-
sessionIdContext?: string;
|
|
79
|
+
secureConnectionListener?: SecureConnectionCallback | undefined;
|
|
80
|
+
};
|
|
81
|
+
export type ServerOpts = LocalOptions & tls.TLSSocketOptions & import("./ca.js").CertOpts & import("./net.js").ServerOpts;
|
|
82
|
+
export type ListenOptions = {
|
|
799
83
|
/**
|
|
800
|
-
*
|
|
801
|
-
* pseudorandom data. See Session Resumption for more information.
|
|
84
|
+
* The port to listen on.
|
|
802
85
|
*/
|
|
803
|
-
|
|
86
|
+
port: number;
|
|
804
87
|
/**
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
* Session Resumption for more information.
|
|
88
|
+
* If it exists,
|
|
89
|
+
* installed as a listener for the 'secureConnection' event.
|
|
808
90
|
*/
|
|
809
|
-
|
|
91
|
+
secureConnectionListener: SecureConnectionCallback;
|
|
810
92
|
};
|
|
811
|
-
import tls from
|
|
812
|
-
import
|
|
93
|
+
import tls from 'node:tls';
|
|
94
|
+
import * as net from './net.js';
|
|
95
|
+
import { CertificateAuthority } from './ca.js';
|