diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-05-05 14:58:38 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-05-05 14:58:38 +0200 |
commit | 36fafda8e3b953d3d1cba91efeb4fc82388b0445 (patch) | |
tree | e0c6c7833a9d71404bc9a62277716e5bea9d036c /eaaf_core_utils/src/test/java | |
parent | 49cb8adfd8992dc8d21ff208d8dd93e0592e1be4 (diff) | |
download | EAAF-Components-36fafda8e3b953d3d1cba91efeb4fc82388b0445.tar.gz EAAF-Components-36fafda8e3b953d3d1cba91efeb4fc82388b0445.tar.bz2 EAAF-Components-36fafda8e3b953d3d1cba91efeb4fc82388b0445.zip |
finish SSLContext creation by using KeyStore from HSM-Facade
Diffstat (limited to 'eaaf_core_utils/src/test/java')
-rw-r--r-- | eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java index 140c74f5..72ec7008 100644 --- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java +++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java @@ -332,30 +332,27 @@ public class HttpClientFactoryTest { @Test public void getCustomClientX509AuthWithHsmFacade() throws EaafException, ClientProtocolException, IOException, KeyStoreException { - final HttpClientConfiguration config = new HttpClientConfiguration("jUnit"); - config.setAuthMode("ssl"); - config.buildKeyStoreConfig( - "hsmfacade", - null, - null, - "authhandler"); - config.setSslKeyPassword("password"); - config.setSslKeyAlias("authhandler-sign"); - config.setDisableTlsHostCertificateValidation(true); + final HttpClientConfiguration clientConfig = new HttpClientConfiguration("jUnit-client"); + clientConfig.setAuthMode("ssl"); + clientConfig.buildKeyStoreConfig("hsmfacade", null, null, "authhandler"); + clientConfig.setSslKeyAlias("authhandler-sign"); + clientConfig.setDisableTlsHostCertificateValidation(true); - final CloseableHttpClient client = httpClientFactory.getHttpClient(config); + + + final CloseableHttpClient client = httpClientFactory.getHttpClient(clientConfig); Assert.assertNotNull("httpClient", client); //set-up mock-up web-server with SSL client authentication final Pair<KeyStore, Provider> sslClientKeyStore = - keyStoreFactory.buildNewKeyStore(config.getKeyStoreConfig()); + keyStoreFactory.buildNewKeyStore(clientConfig.getKeyStoreConfig()); + X509Certificate clientRootCert = (X509Certificate) sslClientKeyStore.getFirst() + .getCertificateChain(clientConfig.getSslKeyAlias())[1]; + final String localhost = InetAddress.getByName("localhost").getCanonicalHostName(); final HeldCertificate localhostCertificate = new HeldCertificate.Builder() .addSubjectAlternativeName(localhost) .build(); - X509Certificate clientRootCert = (X509Certificate) sslClientKeyStore.getFirst() - .getCertificateChain(config.getSslKeyAlias())[1]; - final HandshakeCertificates serverCertificates = new HandshakeCertificates.Builder() .addTrustedCertificate(clientRootCert) .heldCertificate(localhostCertificate) |