X509TrustManager mgr = new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkServerTrusted(X509Certificate[] certificates, String s) {} public void checkClientTrusted(X509Certificate[] certificates, String s) {} }; try { final SSLContext context = SSLContext.getInstance("ssl"); context.init( null, new TrustManager[] { mgr }, new SecureRandom() ); SecureProtocolSocketFactory factory = new SecureProtocolSocketFactory() { public Socket createSocket( Socket socket, String host, int port, boolean autoClose ) throws IOException, UnknownHostException { return context.getSocketFactory().createSocket(socket,host,port,autoClose); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return context.getSocketFactory().createSocket(host,port); } public Socket createSocket(String host, int port, InetAddress localhost, int localport) throws IOException, UnknownHostException { return context.getSocketFactory().createSocket(host,port,localhost,localport); } }; Protocol protocol = new Protocol("https",factory,443); Protocol.registerProtocol("https",protocol); } catch(Exception e) { e.printStackTrace(); }