Skip to content

Fix TLS certificate validation in Java SDK WebSocket relay connections#623

Merged
klvnraju merged 1 commit intomainfrom
dev/nkotchar/Fix31000000590337
Apr 23, 2026
Merged

Fix TLS certificate validation in Java SDK WebSocket relay connections#623
klvnraju merged 1 commit intomainfrom
dev/nkotchar/Fix31000000590337

Conversation

@klvnraju
Copy link
Copy Markdown
Collaborator

@klvnraju klvnraju commented Apr 23, 2026

The Java SDK’s WebSocketConnector did not fully enforce TLS certificate verification for secure relay connections. This reduced the overall security of the connection and could have allowed unauthorized interaction under certain network conditions.

Changes proposed:

  • WebSocketConnector.java: The SSL context now uses the JDK's default trust manager for production relay connections, which properly validates server certificates against the system's trusted CA store.
  • Localhost exceptions are preserved for local development (localhost and tunnels.local.api.visualstudio.com), matching the pattern used by the Go SDK.

Other Tasks:

  • If you updated the Go SDK did you update the PackageVersion in tunnels.go
  • If you updated the TS SDK did you update the dependencies in package.json for connections and management to require a dependency that is > the current published version(Found using npm view @microsoft/dev-tunnels-contracts). This will fix issues where yarn will pull the old version of packages and will cause mismatched dependencies. See example PR

For Sev2.5 31000000590337

The Java SDK's WebSocketConnector used InsecureTrustManagerFactory.INSTANCE for all wss:// relay connections, which bypassed TLS certificate validation entirely. This allowed a man-in-the-middle attacker to intercept the WebSocket
handshake, capture the Authorization: tunnel <connect-token> header, and replay the token against a live tunnel to impersonate the client.

What changed

 - WebSocketConnector.java: The SSL context now uses the JDK's default trust manager for production relay connections, which properly validates server certificates against the system's trusted CA store.
 - Localhost exceptions are preserved for local development (localhost and tunnels.local.api.visualstudio.com), matching the pattern used by the Go SDK.
@klvnraju klvnraju merged commit a047998 into main Apr 23, 2026
11 checks passed
@klvnraju klvnraju deleted the dev/nkotchar/Fix31000000590337 branch April 23, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants