Merge pull request #253 from gasbytes/HttpsURLConnection/ImpactOnSNI-patch

wolfjsse: auto-enable SNI for HttpsURLConnection
pull/255/head
Chris Conlon 2025-02-05 10:03:06 -07:00 committed by GitHub
commit 45810c8fbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 1 deletions

View File

@ -892,6 +892,22 @@ public class WolfSSLEngineHelper {
boolean autoSNI = "true".equalsIgnoreCase(
Security.getProperty("wolfjsse.autoSNI"));
/* Detect HttpsURLConnection usage by checking:
* - Client mode is set (client-side connection)
* - Has hostname from URL
* - Has peer address from socket
* - No explicit SNI configuration
* This pattern is unique to HttpsURLConnection initialization
*/
boolean isHttpsConnection = this.clientMode &&
this.hostname != null &&
this.peerAddr != null &&
this.params.getServerNames() == null;
/* Enable SNI if explicitly requested via property or if
* HttpsURLConnection is detected */
autoSNI = autoSNI || isHttpsConnection;
if (!enableSNI) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"jsse.enableSNIExtension property set to false, " +