Code example for HttpsURLConnection

Methods: setHostnameVerifiersetSSLSocketFactory

0
                context = SSLContext.getInstance("TLS");
                if (secure)
                    context.init(null, TrustManagerFactory.getTrustManagers(), null);
                else { 
                    MyHostnameVerifier verifier = new MyHostnameVerifier();
                    sc.setHostnameVerifier(verifier);
                    context.init(null, TrustManagerFactory.getUnsecureTrustManagers(), null);
                } 
                sc.setSSLSocketFactory(context.getSocketFactory());
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            } catch (KeyManagementException e) {
                e.printStackTrace();
            } 
        } 
    } 
     
    private HttpURLConnection prepareGet(String apiPath, boolean withToken)
            throws IOException { 
        URL url = new URL(account.server + apiPath);
Contextual code suggestions in your IDE  Get Codota for Java