Search in sources :

Example 1 with CertificateAuthority

use of com.github.tomakehurst.wiremock.http.ssl.CertificateAuthority in project wiremock by wiremock.

the class SslContexts method buildKeyStore.

private static X509KeyStore buildKeyStore(KeyStoreSettings browserProxyCaKeyStore) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, CertificateGenerationUnsupportedException {
    final CertificateAuthority certificateAuthority = CertificateAuthority.generateCertificateAuthority();
    KeyStore keyStore = KeyStore.getInstance(browserProxyCaKeyStore.type());
    char[] password = browserProxyCaKeyStore.password().toCharArray();
    keyStore.load(null, password);
    keyStore.setKeyEntry("wiremock-ca", certificateAuthority.key(), password, certificateAuthority.certificateChain());
    browserProxyCaKeyStore.getSource().save(keyStore);
    return new X509KeyStore(keyStore, password);
}
Also used : X509KeyStore(com.github.tomakehurst.wiremock.http.ssl.X509KeyStore) CertificateAuthority(com.github.tomakehurst.wiremock.http.ssl.CertificateAuthority) X509KeyStore(com.github.tomakehurst.wiremock.http.ssl.X509KeyStore) KeyStore(java.security.KeyStore)

Aggregations

CertificateAuthority (com.github.tomakehurst.wiremock.http.ssl.CertificateAuthority)1 X509KeyStore (com.github.tomakehurst.wiremock.http.ssl.X509KeyStore)1 KeyStore (java.security.KeyStore)1