summaryrefslogtreecommitdiff
path: root/eaaf_core_utils/src/test
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-05-05 14:58:38 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-05-05 14:58:38 +0200
commit36fafda8e3b953d3d1cba91efeb4fc82388b0445 (patch)
treee0c6c7833a9d71404bc9a62277716e5bea9d036c /eaaf_core_utils/src/test
parent49cb8adfd8992dc8d21ff208d8dd93e0592e1be4 (diff)
downloadEAAF-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')
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/http/HttpClientFactoryTest.java27
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)