summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/spigotmc/builder/Builder.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java
index ba9ff81..117a14e 100644
--- a/src/main/java/org/spigotmc/builder/Builder.java
+++ b/src/main/java/org/spigotmc/builder/Builder.java
@@ -23,12 +23,21 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
@@ -47,6 +56,11 @@ public class Builder
public static void main(String[] args) throws Exception
{
+ for (String s : args) {
+ if ("--disable-certificate-check".equals(s)) {
+ disableHttpsCertificateCheck();
+ }
+ }
if ( IS_MAC )
{
System.out.println( "Sorry, but Macintosh is not currently a supported platform for compilation at this time." );
@@ -455,4 +469,40 @@ public class Builder
return target;
}
+
+ public static void disableHttpsCertificateCheck() {
+ // This globally disables certificate checking
+ // http://stackoverflow.com/questions/19723415/java-overriding-function-to-disable-ssl-certificate-check
+ try
+ {
+ TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+
+ HostnameVerifier allHostsValid = new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ };
+ HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
+ } catch ( NoSuchAlgorithmException ex )
+ {
+ System.out.println("Failed to disable https certificate check");
+ ex.printStackTrace(System.out);
+ } catch ( KeyManagementException ex )
+ {
+ System.out.println("Failed to disable https certificate check");
+ ex.printStackTrace(System.out);
+ }
+ }
}