Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2015 RDX
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package neembuu.uploader.utils;
- /**
- *
- * @author Paralytic
- */
- import javax.net.ssl.*;
- import java.security.cert.CertificateException;
- import java.security.cert.X509Certificate;
- import javax.net.ssl.HttpsURLConnection;
- public class SSLCertificateValidation {
- public static void disable() {
- try {
- SSLContext sslc = SSLContext.getInstance("TLS");
- TrustManager[] trustManagerArray = { new NullX509TrustManager() };
- sslc.init(null, trustManagerArray, null);
- HttpsURLConnection.setDefaultSSLSocketFactory(sslc.getSocketFactory());
- HttpsURLConnection.setDefaultHostnameVerifier(new NullHostnameVerifier());
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- private static class NullX509TrustManager implements X509TrustManager {
- public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- System.out.println();
- }
- public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- System.out.println();
- }
- public X509Certificate[] getAcceptedIssuers() {
- return new X509Certificate[0];
- }
- }
- private static class NullHostnameVerifier implements HostnameVerifier {
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement