|
23 | 23 | import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
24 | 24 | import org.apache.http.impl.client.CloseableHttpClient;
|
25 | 25 | import org.apache.http.impl.client.HttpClientBuilder;
|
| 26 | +import org.apache.http.ssl.PrivateKeyStrategy; |
26 | 27 | import org.apache.http.ssl.SSLContextBuilder;
|
27 | 28 | import org.apache.http.ssl.SSLContexts;
|
28 | 29 | import org.zowe.apiml.message.log.ApimlLogger;
|
@@ -184,14 +185,21 @@ private void loadKeystoreMaterial(SSLContextBuilder sslContextBuilder) throws Un
|
184 | 185 | }
|
185 | 186 | log.info("Loading key store file: " + config.getKeyStore());
|
186 | 187 | File keyStoreFile = new File(config.getKeyStore());
|
187 |
| - sslContextBuilder.loadKeyMaterial(keyStoreFile, config.getKeyStorePassword(), config.getKeyPassword()); |
| 188 | + sslContextBuilder.loadKeyMaterial( |
| 189 | + keyStoreFile, config.getKeyStorePassword(), config.getKeyPassword(), |
| 190 | + getPrivateKeyStrategy() |
| 191 | + ); |
| 192 | + } |
| 193 | + |
| 194 | + private PrivateKeyStrategy getPrivateKeyStrategy() { |
| 195 | + return config.getKeyAlias() != null ? (aliases, socket) -> config.getKeyAlias() : null; |
188 | 196 | }
|
189 | 197 |
|
190 | 198 | private void loadKeyringMaterial(SSLContextBuilder sslContextBuilder) throws UnrecoverableKeyException,
|
191 | 199 | NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
|
192 | 200 | log.info("Loading trust key ring: " + config.getKeyStore());
|
193 | 201 | sslContextBuilder.loadKeyMaterial(keyRingUrl(config.getKeyStore()), config.getKeyStorePassword(),
|
194 |
| - config.getKeyPassword(), null); |
| 202 | + config.getKeyPassword(), getPrivateKeyStrategy()); |
195 | 203 | }
|
196 | 204 |
|
197 | 205 | private synchronized SSLContext createSecureSslContext() {
|
|
0 commit comments