diff --git a/src/http/UnsecureWebSocketsProtocol.ts b/src/http/UnsecureWebSocketsProtocol.ts index e18e32a63..c4dd153d5 100644 --- a/src/http/UnsecureWebSocketsProtocol.ts +++ b/src/http/UnsecureWebSocketsProtocol.ts @@ -1,4 +1,5 @@ import { EventEmitter } from 'events'; +import type { TLSSocket } from 'tls'; import type { WebSocket } from 'ws'; import { getLoggerFor } from '../logging/LogUtil'; import type { HttpRequest } from '../server/HttpRequest'; @@ -47,7 +48,7 @@ class WebSocketListener extends EventEmitter { // Store the HTTP host and protocol const forwarded = parseForwarded(headers); this.host = forwarded.host ?? headers.host ?? 'localhost'; - this.protocol = forwarded.proto === 'https' || (socket as any).secure ? 'https:' : 'http:'; + this.protocol = forwarded.proto === 'https' || (socket as TLSSocket).encrypted ? 'https:' : 'http:'; } private stop(): void { diff --git a/test/unit/http/UnsecureWebSocketsProtocol.test.ts b/test/unit/http/UnsecureWebSocketsProtocol.test.ts index 0d95c421e..8419ea553 100644 --- a/test/unit/http/UnsecureWebSocketsProtocol.test.ts +++ b/test/unit/http/UnsecureWebSocketsProtocol.test.ts @@ -25,7 +25,7 @@ describe('An UnsecureWebSocketsProtocol', (): void => { 'sec-websocket-protocol': 'solid-0.1, other/1.0.0', }, socket: { - secure: true, + encrypted: true, }, } as any as HttpRequest; await protocol.handle({ webSocket, upgradeRequest } as any);