public HttpsCertificate getCertificate() { return certificate(Moco.file(filename), keystore, cert); } }
@Override public SslHandler apply(final HttpsCertificate certificate) { SSLEngine sslEngine = certificate.createSSLEngine(); sslEngine.setUseClientMode(false); return new SslHandler(sslEngine); } };
public SSLEngine createSSLEngine() { return createServerContext().createSSLEngine(); }
private SSLContext createServerContext() { InputStream is = this.getKeyStore(); try { KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(is, this.getKeyStorePassword()); KeyManagerFactory factory = KeyManagerFactory.getInstance(getAlgorithm()); factory.init(keyStore, this.getCertPassword()); SSLContext serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(factory.getKeyManagers(), null, null); return serverContext; } catch (Exception e) { throw new MocoException("Failed to initialize the server-side SSLContext", e); } finally { Closeables.closeQuietly(is); } }
public static HttpsCertificate certificate(final ContentResource resource, final String keyStorePassword, final String certPassword) { return new HttpsCertificate(checkNotNull(resource), checkNotNullOrEmpty(keyStorePassword, "Key store password should not be null"), checkNotNullOrEmpty(certPassword, "Cert password should not be null")); } }
@Before public void setup() { HttpsServer server = httpsServer(port(), certificate(pathResource("cert.jks"), "mocohttps", "mocohttps")); server.response("foo"); this.runner = Runner.runner(server); runner.start(); helper = new MocoTestHelper(); }
public HttpsCertificate getCertificate() { return certificate(Moco.file(filename), keystore, cert); } }