Skip to content

Commit 89229ec

Browse files
committed
Update read-tls-client-hello to add JA4 fingerprint to TLS events
1 parent c9c4438 commit 89229ec

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"parse-multipart-data": "^1.4.0",
195195
"performance-now": "^2.1.0",
196196
"portfinder": "^1.0.32",
197-
"read-tls-client-hello": "^1.0.0",
197+
"read-tls-client-hello": "^1.1.0",
198198
"semver": "^7.5.3",
199199
"socks-proxy-agent": "^7.0.0",
200200
"typed-error": "^3.0.2",

src/server/http-combo-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { makeDestroyable, DestroyableServer } from 'destroyable-server';
1111
import httpolyglot = require('@httptoolkit/httpolyglot');
1212
import {
1313
calculateJa3FromFingerprintData,
14+
calculateJa4FromHelloData,
1415
NonTlsError,
1516
readTlsClientHello
1617
} from 'read-tls-client-hello';
@@ -399,7 +400,8 @@ function analyzeAndMaybePassThroughTls(
399400
connectHostname,
400401
connectPort,
401402
clientAlpn: helloData.alpnProtocols,
402-
ja3Fingerprint: calculateJa3FromFingerprintData(helloData.fingerprintData)
403+
ja3Fingerprint: calculateJa3FromFingerprintData(helloData.fingerprintData),
404+
ja4Fingerprint: calculateJa4FromHelloData(helloData)
403405
};
404406

405407
if (shouldPassThrough(connectHostname, passThroughPatterns, interceptOnlyPatterns)) {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface TlsSocketMetadata {
8484
connectPort?: string;
8585
clientAlpn?: string[];
8686
ja3Fingerprint?: string;
87+
ja4Fingerprint?: string;
8788
}
8889

8990
export interface TlsPassthroughEvent extends TlsConnectionEvent {

test/integration/subscriptions/tls-error-events.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe("TLS error subscriptions", () => {
108108

109109
expect(tlsError.tlsMetadata.sniHostname).to.equal('localhost');
110110
expect(tlsError.tlsMetadata.ja3Fingerprint!.length).to.equal(32);
111+
expect(tlsError.tlsMetadata.ja4Fingerprint!.length).to.equal(36);
111112

112113
await expectNoClientErrors();
113114
});

test/integration/subscriptions/tls-passthrough-events.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ describe("TLS passthrough subscriptions", () => {
5353
: ['h2', 'http/1.1']
5454
);
5555
expect(tlsMetadata.ja3Fingerprint.length).to.equal(32);
56+
expect(tlsMetadata.ja4Fingerprint.length).to.equal(36);
5657
});
5758

5859
it("should not fire for TLS sockets are received and handled", async () => {

0 commit comments

Comments
 (0)