@Before public void startServer() throws NoSuchAlgorithmException, KeyManagementException, IOException { server = server() .withHttpsEnabled() .usingDatabaseDir(folder.cleanDirectory(name.getMethodName()).getAbsolutePath()) .build(); httpsUri = server.httpsUri().toASCIIString(); // Because we are generating a non-CA-signed certificate, we need to turn off verification in // the client. // This is ironic, since there is no proper verification on the CA side in the first place, but // I digress. TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {} public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {} public X509Certificate[] getAcceptedIssuers() { return null; } } }; // Install the all-trusting trust manager SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); }