Skip to content

Commit 300dd96

Browse files
author
root
committed
Add a function for testing env
Caution: MIM Attack
1 parent c4da2c2 commit 300dd96

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

io/github/javaherobrine/net/TLSUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,20 @@ public static SSLContext getFromKSFile(String file,String version,String encrypt
2121
context.init(km.getKeyManagers(),tmf.getTrustManagers(),null);
2222
return context;
2323
}
24+
@Deprecated
25+
public static SSLContext trustAllCert() throws KeyManagementException, NoSuchAlgorithmException {//man in middle is a problem
26+
SSLContext ssl=SSLContext.getInstance("SSL");
27+
ssl.init(null,new TrustManager[] {new X509TrustManager() {
28+
@Override
29+
public void checkClientTrusted(X509Certificate[] c,String s) {}
30+
@Override
31+
public void checkServerTrusted(X509Certificate[] c,String s) {}
32+
@Override
33+
public X509Certificate[] getAcceptedIssuers() {
34+
return null;
35+
}
36+
}
37+
},new SecureRandom());
38+
return ssl;
39+
}
2440
}

0 commit comments

Comments
 (0)