mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-07 21:05:58 +00:00
Added version check to certificate addition
This commit is contained in:
@@ -26,6 +26,7 @@ import io.netty.handler.traffic.GlobalTrafficShapingHandler;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.lang.System;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@@ -114,6 +115,9 @@ public final class NetworkUtils
|
|||||||
|
|
||||||
TrustManagerFactory tmf = null;
|
TrustManagerFactory tmf = null;
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
String version = System.getProperty( "java.version" );
|
||||||
|
if ( version.regionMatches( 0, "1.8.0_", 0, 6 ) && version.length() == 8 ) // 1.8.0_xx (xx < 100)
|
||||||
{
|
{
|
||||||
Certificate ca = CertificateFactory.getInstance( "X.509" )
|
Certificate ca = CertificateFactory.getInstance( "X.509" )
|
||||||
.generateCertificate( new ByteArrayInputStream( letsEncryptRootCert.getBytes() ) );
|
.generateCertificate( new ByteArrayInputStream( letsEncryptRootCert.getBytes() ) );
|
||||||
@@ -137,6 +141,11 @@ public final class NetworkUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmf = new MergedTrustManagerFactory( TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() ), x509tm );
|
tmf = new MergedTrustManagerFactory( TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() ), x509tm );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmf = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
|
||||||
|
}
|
||||||
tmf.init( (KeyStore) null );
|
tmf.init( (KeyStore) null );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
Reference in New Issue
Block a user