From 36fafda8e3b953d3d1cba91efeb4fc82388b0445 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 5 May 2020 14:58:38 +0200 Subject: finish SSLContext creation by using KeyStore from HSM-Facade --- .../eaaf/core/test/http/HttpClientFactoryTest.java | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java') 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 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) -- cgit v1.2.3