@@ -173,6 +173,8 @@ specifying a cipher suite with the `ciphers` option. The list of available
173
173
ciphers can be retrieved via ` openssl ciphers -v 'PSK' ` . All TLS 1.3
174
174
ciphers are eligible for PSK and can be retrieved via
175
175
` openssl ciphers -v -s -tls1_3 -psk ` .
176
+ On the client connection, a custom ` checkServerIdentity ` should be passed
177
+ because the default one will fail in the absence of a certificate.
176
178
177
179
According to the [ RFC 4279] [ ] , PSK identities up to 128 bytes in length and
178
180
PSKs up to 64 bytes in length must be supported. As of OpenSSL 1.1.0
@@ -181,6 +183,30 @@ maximum identity size is 128 bytes, and maximum PSK length is 256 bytes.
181
183
The current implementation doesn't support asynchronous PSK callbacks due to the
182
184
limitations of the underlying OpenSSL API.
183
185
186
+ To use TLS-PSK, client and server must specify the ` pskCallback ` option,
187
+ a function that returns the PSK to use (which must be compatible with
188
+ the selected cipher's digest).
189
+
190
+ It will be called first on the client:
191
+
192
+ * hint: {string} optional message sent from the server to help the client
193
+ decide which identity to use during negotiation.
194
+ Always ` null ` if TLS 1.3 is used.
195
+ * Returns: {Object} in the form
196
+ ` { psk: <Buffer|TypedArray|DataView>, identity: <string> } ` or ` null ` .
197
+
198
+ Then on the server:
199
+
200
+ * socket: {tls.TLSSocket} the server socket instance, equivalent to ` this ` .
201
+ * identity: {string} identity parameter sent from the client.
202
+ * Returns: {Buffer|TypedArray|DataView} the PSK (or ` null ` ).
203
+
204
+ A return value of ` null ` stops the negotiation process and sends an
205
+ ` unknown_psk_identity ` alert message to the other party.
206
+ If the server wishes to hide the fact that the PSK identity was not known,
207
+ the callback must provide some random data as ` psk ` to make the connection
208
+ fail with ` decrypt_error ` before negotiation is finished.
209
+
184
210
### Client-initiated renegotiation attack mitigation
185
211
186
212
<!-- type=misc -->
@@ -1646,25 +1672,7 @@ changes:
1646
1672
verified against the list of supplied CAs. An ` 'error' ` event is emitted if
1647
1673
verification fails; ` err.code ` contains the OpenSSL error code. ** Default:**
1648
1674
` true ` .
1649
- * ` pskCallback ` {Function}
1650
-
1651
- * hint: {string} optional message sent from the server to help client
1652
- decide which identity to use during negotiation.
1653
- Always ` null ` if TLS 1.3 is used.
1654
- * Returns: {Object} An object in the form
1655
- ` { psk: <Buffer|TypedArray|DataView>, identity: <string> } `
1656
- or ` null ` to stop the negotiation process. ` psk ` must be
1657
- compatible with the selected cipher's digest.
1658
- ` identity ` must use UTF-8 encoding.
1659
-
1660
- When negotiating TLS-PSK (pre-shared keys), this function is called
1661
- with optional identity ` hint ` provided by the server or ` null `
1662
- in case of TLS 1.3 where ` hint ` was removed.
1663
- It will be necessary to provide a custom ` tls.checkServerIdentity() `
1664
- for the connection as the default one will try to check host name/IP
1665
- of the server against the certificate but that's not applicable for PSK
1666
- because there won't be a certificate present.
1667
- More information can be found in the [ RFC 4279] [ ] .
1675
+ * ` pskCallback ` {Function} For TLS-PSK negotiation, see [ Pre-shared keys] [ ] .
1668
1676
* ` ALPNProtocols ` : {string\[ ] |Buffer\[ ] |TypedArray\[ ] |DataView\[ ] |Buffer|
1669
1677
TypedArray|DataView}
1670
1678
An array of strings, ` Buffer ` s, ` TypedArray ` s, or ` DataView ` s, or a
@@ -2123,25 +2131,7 @@ changes:
2123
2131
default callback with high-level API will be used (see below).
2124
2132
* ` ticketKeys ` : {Buffer} 48-bytes of cryptographically strong pseudorandom
2125
2133
data. See [ Session Resumption] [ ] for more information.
2126
- * ` pskCallback ` {Function}
2127
-
2128
- * socket: {tls.TLSSocket} the server [ ` tls.TLSSocket ` ] [ ] instance for
2129
- this connection.
2130
- * identity: {string} identity parameter sent from the client.
2131
- * Returns: {Buffer|TypedArray|DataView} pre-shared key that must either be
2132
- a buffer or ` null ` to stop the negotiation process. Returned PSK must be
2133
- compatible with the selected cipher's digest.
2134
-
2135
- When negotiating TLS-PSK (pre-shared keys), this function is called
2136
- with the identity provided by the client.
2137
- If the return value is ` null ` the negotiation process will stop and an
2138
- "unknown\_ psk\_ identity" alert message will be sent to the other party.
2139
- If the server wishes to hide the fact that the PSK identity was not known,
2140
- the callback must provide some random data as ` psk ` to make the connection
2141
- fail with "decrypt\_ error" before negotiation is finished.
2142
- PSK ciphers are disabled by default, and using TLS-PSK thus
2143
- requires explicitly specifying a cipher suite with the ` ciphers ` option.
2144
- More information can be found in the [ RFC 4279] [ ] .
2134
+ * ` pskCallback ` {Function} For TLS-PSK negotiation, see [ Pre-shared keys] [ ] .
2145
2135
* ` pskIdentityHint ` {string} optional hint to send to a client to help
2146
2136
with selecting the identity during TLS-PSK negotiation. Will be ignored
2147
2137
in TLS 1.3. Upon failing to set pskIdentityHint ` 'tlsClientError' ` will be
@@ -2292,6 +2282,7 @@ added:
2292
2282
[ Mozilla's publicly trusted list of CAs ] : https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt
2293
2283
[ OCSP request ] : https://en.wikipedia.org/wiki/OCSP_stapling
2294
2284
[ OpenSSL Options ] : crypto.md#openssl-options
2285
+ [ Pre-shared keys ] : #pre-shared-keys
2295
2286
[ RFC 2246 ] : https://www.ietf.org/rfc/rfc2246.txt
2296
2287
[ RFC 4086 ] : https://tools.ietf.org/html/rfc4086
2297
2288
[ RFC 4279 ] : https://tools.ietf.org/html/rfc4279
0 commit comments