@@ -80,6 +80,7 @@ public void testConnection()
8080 private final Path trustStorePath ;
8181 private final Path certificatePath ;
8282 private final Path privateKeyPath ;
83+ private final char [] privateKeyPassword ;
8384
8485 private final String fttpServerBase ;
8586 private final String fttpBasicAuthUsername ;
@@ -99,14 +100,15 @@ public void testConnection()
99100
100101 private final boolean hapiClientVerbose ;
101102
102- public FttpClientFactory (Path trustStorePath , Path certificatePath , Path privateKeyPath , int connectTimeout ,
103- int socketTimeout , int connectionRequestTimeout , String fttpBasicAuthUsername , String fttpBasicAuthPassword ,
104- String fttpServerBase , String fttpApiKey , String fttpStudy , String fttpTarget , String proxySchemeHostPort ,
105- String proxyUsername , String proxyPassword , boolean hapiClientVerbose )
103+ public FttpClientFactory (Path trustStorePath , Path certificatePath , Path privateKeyPath , char [] privateKeyPassword ,
104+ int connectTimeout , int socketTimeout , int connectionRequestTimeout , String fttpBasicAuthUsername ,
105+ String fttpBasicAuthPassword , String fttpServerBase , String fttpApiKey , String fttpStudy , String fttpTarget ,
106+ String proxySchemeHostPort , String proxyUsername , String proxyPassword , boolean hapiClientVerbose )
106107 {
107108 this .trustStorePath = trustStorePath ;
108109 this .certificatePath = certificatePath ;
109110 this .privateKeyPath = privateKeyPath ;
111+ this .privateKeyPassword = privateKeyPassword ;
110112
111113 this .connectTimeout = connectTimeout ;
112114 this .socketTimeout = socketTimeout ;
@@ -133,8 +135,9 @@ public void onContextRefreshedEvent(ContextRefreshedEvent event)
133135 try
134136 {
135137 logger .info (
136- "Testing connection to fTTP with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, fttpServerBase: {}, fttpApiKey: {}, fttpStudy: {}, fttpTarget: {}}" ,
137- trustStorePath , certificatePath , privateKeyPath , fttpServerBase , fttpApiKey , fttpStudy , fttpTarget );
138+ "Testing connection to fTTP with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, privateKeyPassword: {}, fttpServerBase: {}, fttpApiKey: {}, fttpStudy: {}, fttpTarget: {}}" ,
139+ trustStorePath , certificatePath , privateKeyPath , privateKeyPassword != null ? "***" : "null" ,
140+ fttpServerBase , fttpApiKey , fttpStudy , fttpTarget );
138141
139142 getFttpClient ().testConnection ();
140143 }
@@ -166,7 +169,7 @@ protected FttpClient createFttpClient()
166169 char [] keyStorePassword = UUID .randomUUID ().toString ().toCharArray ();
167170
168171 logger .debug ("Creating key-store from {} and {}" , certificatePath .toString (), privateKeyPath .toString ());
169- KeyStore keyStore = readKeyStore (certificatePath , privateKeyPath , keyStorePassword );
172+ KeyStore keyStore = readKeyStore (certificatePath , privateKeyPath , privateKeyPassword , keyStorePassword );
170173
171174 return new FttpClientImpl (trustStore , keyStore , keyStorePassword , connectTimeout , socketTimeout ,
172175 connectionRequestTimeout , fttpBasicAuthUsername , fttpBasicAuthPassword , fttpServerBase , fttpApiKey ,
@@ -185,11 +188,11 @@ private KeyStore readTrustStore(Path trustPath)
185188 }
186189 }
187190
188- private KeyStore readKeyStore (Path certificatePath , Path keyPath , char [] keyStorePassword )
191+ private KeyStore readKeyStore (Path certificatePath , Path keyPath , char [] keyPassword , char [] keyStorePassword )
189192 {
190193 try
191194 {
192- PrivateKey privateKey = PemIo .readPrivateKeyFromPem (keyPath );
195+ PrivateKey privateKey = PemIo .readPrivateKeyFromPem (keyPath , keyPassword );
193196 X509Certificate certificate = PemIo .readX509CertificateFromPem (certificatePath );
194197
195198 return CertificateHelper .toJksKeyStore (privateKey , new Certificate [] { certificate },
0 commit comments