1 | import javax.net.ssl.*; |
2 | import java.security.SecureRandom; |
3 | import java.security.cert.X509Certificate; |
4 | |
5 | static volatile bool disableCertificateValidation_attempted; |
6 | |
7 | static void disableCertificateValidation() ctex { |
8 | if (disableCertificateValidation_attempted) ret; |
9 | set disableCertificateValidation_attempted; |
10 | print("Disabling certificate validation for whole VM"); |
11 | |
12 | pcall { |
13 | // Create a trust manager that does not validate certificate chains |
14 | TrustManager[] trustAllCerts = new TrustManager[] { |
15 | new X509TrustManager() { |
16 | public X509Certificate[] getAcceptedIssuers() { |
17 | return new X509Certificate[0]; |
18 | } |
19 | public void checkClientTrusted(X509Certificate[] certs, String authType) {} |
20 | public void checkServerTrusted(X509Certificate[] certs, String authType) {} |
21 | }}; |
22 | |
23 | // Ignore differences between given hostname and certificate hostname |
24 | HostnameVerifier hv = new HostnameVerifier() { |
25 | public boolean verify(String hostname, SSLSession session) { return true; } |
26 | }; |
27 | |
28 | // Install the all-trusting trust manager |
29 | SSLContext sc = SSLContext.getInstance("SSL"); |
30 | sc.init(null, trustAllCerts, new SecureRandom()); |
31 | HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); |
32 | HttpsURLConnection.setDefaultHostnameVerifier(hv); |
33 | } |
34 | } |
from https://stackoverflow.com/questions/875467/java-client-certificates-over-https-ssl
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1013484 |
Snippet name: | disableCertificateValidation |
Eternal ID of this version: | #1013484/5 |
Text MD5: | acd2e6fa3f4c34fa66d336a119898b2d |
Author: | stefan |
Category: | javax / ssl |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-06 15:47:11 |
Source code size: | 1366 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 438 / 490 |
Version history: | 4 change(s) |
Referenced in: | [show references] |