File tree 1 file changed +17
-1
lines changed
src/java/com/wolfssl/provider/jsse
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -890,7 +890,23 @@ private void setLocalServerNames() {
890
890
* This allows users to enable legacy hostname-based SNI behavior
891
891
* through java.security configuration rather than JVM arguments. */
892
892
boolean autoSNI = "true" .equalsIgnoreCase (
893
- Security .getProperty ("wolfjsse.autoSNI" ));
893
+ Security .getProperty ("wolfjsse.autoSNI" ));
894
+
895
+ /* Detect HttpsURLConnection usage by checking:
896
+ * - Client mode is set (client-side connection)
897
+ * - Has hostname from URL
898
+ * - Has peer address from socket
899
+ * - No explicit SNI configuration
900
+ * This pattern is unique to HttpsURLConnection initialization
901
+ */
902
+ boolean isHttpsConnection = this .clientMode &&
903
+ this .hostname != null &&
904
+ this .peerAddr != null &&
905
+ this .params .getServerNames () == null ;
906
+
907
+ /* Enable SNI if explicitly requested via property or if
908
+ * HttpsURLConnection is detected */
909
+ autoSNI = autoSNI || isHttpsConnection ;
894
910
895
911
if (!enableSNI ) {
896
912
WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
You can’t perform that action at this time.
0 commit comments