Skip to content

Commit b680589

Browse files
committed
docs: fix WebSockets double encryption
Rewords the Encryption section to allow for opt-in single encryption signaled via a noise extension.
1 parent 17c7ccc commit b680589

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

noise/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ syntax = "proto2";
221221
message NoiseExtensions {
222222
repeated bytes webtransport_certhashes = 1;
223223
repeated string stream_muxers = 2;
224+
optional bool handshake_only = 3;
224225
}
225226
226227
message NoiseHandshakePayload {

websockets/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,27 @@ WebSockets have no built in authentication mechanism. Server-side processes list
5050

5151
## Encryption
5252

53-
At the time of writing, the negotiated authentication mechanism should also be used to encrypt all traffic sent over the WebSocket even if TLS certificates are also used at the transport layer.
53+
Server-side processes listening on WebSocket addresses should use TLS certificates to secure transmitted data at the transport level.
5454

55-
A mechanism to avoid this but also maintain backwards compatibility with existing server-side processes will be specified in a future revision to this spec.
55+
This does not provide any assurance that the remote peer possesses the private key that corresponds to their public key, so an additional handshake is necessary.
56+
57+
During connection establishment over WebSockets, before the connection is made available to the rest of the application, if all of the following criteria are met:
58+
59+
1. `noise` is negotiated as the connection encryption protocol
60+
2. An initial handshake is performed with the `handshake_only` boolean extension set to true
61+
3. The transport layer is secured by TLS
62+
63+
Then all subsequent data is sent without encrypting it at the libp2p level, instead relying on TLS encryption at the transport layer.
64+
65+
If any of the above is not true, all data is encrypted with the negotiated connection encryption method before sending.
66+
67+
This prevents double-encryption but only when both ends opt-in to ensure backwards compatibility with existing deployments.
68+
69+
### MITM mitigation
70+
71+
The TLS certificate used should be signed by a trusted certificate authority, and the host name should correspond to the common name contained within the certificate.
72+
73+
This requires trusting the certificate authority to issue correct certificates, but is necessary due to limitations of certain user agents, namely web browsers which do not allow use of self-signed certificates that could be otherwise be verified via preshared certificate fingerprints.
5674

5775
## Addressing
5876

0 commit comments

Comments
 (0)