@@ -45,11 +45,11 @@ public class HttpService {
4545
4646 private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier () {
4747 public boolean verify (String s , SSLSession sslSession ) {
48- if (s .equals (HOSTNAME )){
49- return true ;
50- }else {
48+ if (s .equals (HOSTNAME )) {
49+ return true ;
50+ } else {
5151 HostnameVerifier hv = HttpsURLConnection .getDefaultHostnameVerifier ();
52- return hv .verify (s ,sslSession );
52+ return hv .verify (s , sslSession );
5353 }
5454 }
5555 };
@@ -536,14 +536,14 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) {
536536 };
537537 try {
538538 String contextStr = "" ;
539- if (sslSecurityProtocol != null ){
540- contextStr = sslSecurityProtocol .toString ().contains ("SSL" )? "SSL" : "TLSv1.2 " ;
541- }else if (useTLS || System .getProperty ("java.version" ).compareTo ("1.8" )>= 0 ) {
542- contextStr = "TLSv1.2 " ;
543- }else {
539+ if (sslSecurityProtocol != null ) {
540+ contextStr = sslSecurityProtocol .toString ().contains ("SSL" ) ? "SSL" : "TLS " ;
541+ } else if (useTLS || System .getProperty ("java.version" ).compareTo ("1.8" ) >= 0 ) {
542+ contextStr = "TLS " ;
543+ } else {
544544 contextStr = "SSL" ;
545545 }
546- SSLContext context = SSLContext .getInstance ("TLSv1.2" );
546+ SSLContext context = SSLContext .getInstance (contextStr );
547547
548548 context .init (null , trustAll , new java .security .SecureRandom ());
549549 return new SplunkHttpsSocketFactory (context .getSocketFactory ());
@@ -556,20 +556,20 @@ private static final class SplunkHttpsSocketFactory extends SSLSocketFactory {
556556 private final SSLSocketFactory delegate ;
557557
558558 public static String [] PROTOCOLS = {"SSLv3" };
559- public static String [] PROTOCOLS_TLS = {"TLSv1.2" ,"TLSv1.1" ,"TLSv1" };
559+ public static String [] PROTOCOLS_TLS = {"TLSv1.3" , "TLSv1. 2" , "TLSv1.1" , "TLSv1" };
560560
561561 private SplunkHttpsSocketFactory (SSLSocketFactory delegate ) {
562562 this .delegate = delegate ;
563563 }
564564
565565 private Socket configure (Socket socket ) {
566566 if (socket instanceof SSLSocket ) {
567- if (sslSecurityProtocol != null ){
568- String [] protocols = {sslSecurityProtocol .toString ()};
567+ if (sslSecurityProtocol != null ) {
568+ String [] protocols = {sslSecurityProtocol .toString ()};
569569 ((SSLSocket ) socket ).setEnabledProtocols (protocols );
570- }else if (useTLS || System .getProperty ("java.version" ).compareTo ("1.8" )>= 0 ) {
570+ } else if (useTLS || System .getProperty ("java.version" ).compareTo ("1.8" ) >= 0 ) {
571571 ((SSLSocket ) socket ).setEnabledProtocols (PROTOCOLS_TLS );
572- }else {
572+ } else {
573573 ((SSLSocket ) socket ).setEnabledProtocols (PROTOCOLS );
574574 }
575575 }
0 commit comments