You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,26 @@ Be aware that fingerprinting is _not_ a 100% reliable test. Most clients can mod
12
12
13
13
## Docs
14
14
15
-
The easiest way to use this is with the exported `enableFingerprinting` helper, which can be applied to any `tls.TLSServer` instance, including `https.Server` instances, like so:
15
+
### Reading a TLS client hello
16
+
17
+
To read all available data from a TLS client hello, pass a stream (e.g. a `net.Socket`) to the exported `readTlsClientHello(stream)`, before the TLS handshake (or any other processing) starts. This returns a promise containing all data parsed from the client hello.
18
+
19
+
This method reads the initial data from the socket, parses it, and then unshifts it back into the socket, so that once the returned promise resolves the stream can be used like new, to start a normal TLS session using the same client hello.
20
+
21
+
If parsing fails, this method will throw an error, but will still ensure all data is returned to the socket first, so that non-TLS streams can also be processed as normal.
22
+
23
+
The returned promise resolves to an object, containing:
24
+
25
+
*`serverName` - The server name requested in the client hello (or undefined if SNI was not used)
26
+
*`fingerprintData` - The raw components used for JA3 TLS fingerprinting (see the next section)
27
+
28
+
### TLS fingerprinting
29
+
30
+
The easiest way to use this for fingerprinting is with the exported `enableFingerprinting` helper, which can be applied to any `tls.TLSServer` instance, including `https.Server` instances, like so:
constserver=newhttps.Server({ /* your TLS options etc */ });
22
37
@@ -40,6 +55,6 @@ The `tlsFingerprint` property contains two fields:
40
55
41
56
It is also possible to calculate TLS fingerprints manually. The module exports a few methods for this:
42
57
43
-
*`getTlsFingerprintData(stream)` - Reads from a stream of incoming TLS client data, returning a promise for the raw fingerprint data, and unshifting the data back into the stream when it's done. Nothing else should attempt to read from the stream until the returned promise resolves (i.e. don't start TLS negotiation until this completes).
44
-
*`getTlsFingerprintAsJa3` - Reads from a streamlike `getTlsFingerprintData` but returns a promise for the JA3 hash, instead of raw data.
58
+
*`readTlsClientHello(stream)` - Reads from a stream of incoming TLS client data, returning a promise for parsed TLS hello, and unshifting the data back into the stream when it's done. Nothing else should attempt to read from the stream until the returned promise resolves (i.e. don't start TLS negotiation until this completes). The `fingerprintData` of the resulting value contains the raw fingerprint components.
59
+
*`getTlsFingerprintAsJa3` - Reads from a stream, just like `readTlsClientHello`, but returns a promise for the JA3 hash, instead of raw hello data.
45
60
*`calculateJa3FromFingerprintData(data)` - Takes raw TLS fingerprint data, and returns the corresponding JA3 hash.
0 commit comments