@@ -0,0 +1,1971 @@
+package org.mcupdater.downloadlib;%0A%0Aimport javax.net.ssl.HttpsURLConnection;%0Aimport javax.net.ssl.SSLContext;%0Aimport javax.net.ssl.TrustManagerFactory;%0Aimport java.io.InputStream;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.security.KeyManagementException;%0Aimport java.security.KeyStore;%0Aimport java.security.KeyStoreException;%0Aimport java.security.NoSuchAlgorithmException;%0Aimport java.security.cert.Certificate;%0Aimport java.security.cert.CertificateFactory;%0Aimport java.util.Enumeration;%0A%0Apublic class SSLExpansion %7B%0A%09private static SSLExpansion instance;%0A%09private KeyStore keyStore;%0A%0A%09public static SSLExpansion getInstance() %7B%0A%09%09if (instance == null) %7B%0A%09%09%09try %7B%0A%09%09%09%09instance = new SSLExpansion();%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return instance;%0A%09%7D%0A%0A%09public SSLExpansion() throws Exception %7B%0A%09%09keyStore = KeyStore.getInstance(KeyStore.getDefaultType());%0A%09%09Path ksPath = Paths.get(System.getProperty(%22java.home%22)).resolve(%22lib%22).resolve(%22security%22).resolve(%22cacerts%22);%0A%09%09String ksPassword = %22changeit%22;%0A%09%09keyStore.load(Files.newInputStream(ksPath), ksPassword.toCharArray());%0A%09%7D%0A%0A%09public void addCertificateFromStream(InputStream cert, String alias) throws Exception %7B%0A%09%09Certificate ca = CertificateFactory.getInstance(%22X.509%22).generateCertificate(cert);%0A%09%09keyStore.setCertificateEntry(alias, ca);%0A%09%7D%0A%0A%09public void updateSSLContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException %7B%0A%09%09TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());%0A%09%09tmf.init(keyStore);%0A%09%09for (Enumeration%3CString%3E elements = keyStore.aliases(); elements.hasMoreElements(); ) %7B%0A%09%09%09System.out.println(%22@ %22 + elements.nextElement());%0A%09%09%7D%0A%09%09System.out.println();%0A%09%09SSLContext ctx = SSLContext.getInstance(%22TLS%22);%0A%09%09ctx.init(null, tmf.getTrustManagers(), null);%0A%09%09HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());%0A%09%7D%0A%0A%7D%0A

Add SSLExpansion