Skip to content

Commit

Permalink
Update read-tls-client-hello to add JA4 fingerprint to TLS events
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Feb 21, 2025
1 parent c9c4438 commit 89229ec
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"parse-multipart-data": "^1.4.0",
"performance-now": "^2.1.0",
"portfinder": "^1.0.32",
"read-tls-client-hello": "^1.0.0",
"read-tls-client-hello": "^1.1.0",
"semver": "^7.5.3",
"socks-proxy-agent": "^7.0.0",
"typed-error": "^3.0.2",
Expand Down
4 changes: 3 additions & 1 deletion src/server/http-combo-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { makeDestroyable, DestroyableServer } from 'destroyable-server';
import httpolyglot = require('@httptoolkit/httpolyglot');
import {
calculateJa3FromFingerprintData,
calculateJa4FromHelloData,
NonTlsError,
readTlsClientHello
} from 'read-tls-client-hello';
Expand Down Expand Up @@ -399,7 +400,8 @@ function analyzeAndMaybePassThroughTls(
connectHostname,
connectPort,
clientAlpn: helloData.alpnProtocols,
ja3Fingerprint: calculateJa3FromFingerprintData(helloData.fingerprintData)
ja3Fingerprint: calculateJa3FromFingerprintData(helloData.fingerprintData),
ja4Fingerprint: calculateJa4FromHelloData(helloData)
};

if (shouldPassThrough(connectHostname, passThroughPatterns, interceptOnlyPatterns)) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface TlsSocketMetadata {
connectPort?: string;
clientAlpn?: string[];
ja3Fingerprint?: string;
ja4Fingerprint?: string;
}

export interface TlsPassthroughEvent extends TlsConnectionEvent {
Expand Down
1 change: 1 addition & 0 deletions test/integration/subscriptions/tls-error-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe("TLS error subscriptions", () => {

expect(tlsError.tlsMetadata.sniHostname).to.equal('localhost');
expect(tlsError.tlsMetadata.ja3Fingerprint!.length).to.equal(32);
expect(tlsError.tlsMetadata.ja4Fingerprint!.length).to.equal(36);

await expectNoClientErrors();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe("TLS passthrough subscriptions", () => {
: ['h2', 'http/1.1']
);
expect(tlsMetadata.ja3Fingerprint.length).to.equal(32);
expect(tlsMetadata.ja4Fingerprint.length).to.equal(36);
});

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

0 comments on commit 89229ec

Please sign in to comment.