@@ -3,12 +3,14 @@ import * as crypto from 'node:crypto';
33import * as stream from 'stream' ;
44import { EventEmitter } from 'events' ;
55
6+ import { ErrorLike } from '@httptoolkit/util' ;
7+ import { getExtensionData } from 'read-tls-client-hello' ;
8+
69import { ConnectionProcessor } from './process-connection.js' ;
710import { LocalCA } from './tls-certificates/local-ca.js' ;
811import { CertOptions , calculateCertCacheKey } from './tls-certificates/cert-definitions.js' ;
912import { SecureContextCache } from './tls-certificates/secure-context-cache.js' ;
1013import { tlsEndpoints } from './endpoints/endpoint-index.js' ;
11- import { ErrorLike } from '@httptoolkit/util' ;
1214import { PROXY_PROTOCOL } from './proxy-protocol.js' ;
1315import { TLS_CLIENT_HELLO } from './tls-client-hello.js' ;
1416
@@ -137,7 +139,10 @@ class TlsConnectionHandler {
137139
138140 async handleConnection ( rawSocket : stream . Duplex ) {
139141 try {
140- const serverName = rawSocket [ TLS_CLIENT_HELLO ] ?. serverName ;
142+ const tlsClientHello = rawSocket [ TLS_CLIENT_HELLO ] ;
143+ const serverName = tlsClientHello
144+ ? getExtensionData ( tlsClientHello , 'sni' ) ?. serverName
145+ : undefined ;
141146 const domain = serverName || this . tlsConfig . rootDomain ;
142147
143148 const serverNameParts = getSNIPrefixParts ( domain , this . tlsConfig . rootDomain ) ;
@@ -185,8 +190,9 @@ class TlsConnectionHandler {
185190 : DEFAULT_ALPN_PROTOCOLS ;
186191
187192 // Check if client requested OCSP stapling (extension 5 = status_request)
188- const clientExtensions = rawSocket [ TLS_CLIENT_HELLO ] ?. fingerprintData ?. [ 2 ] ;
189- const clientRequestedOCSP = clientExtensions ?. includes ( 5 ) ?? false ;
193+ const clientRequestedOCSP = tlsClientHello
194+ ? ! ! getExtensionData ( tlsClientHello , 'status_request' )
195+ : false ;
190196
191197 const tlsSocket = new tls . TLSSocket ( rawSocket , {
192198 isServer : true ,
0 commit comments