I have the Java method:
String xmlRespuesta = "";
try {
KeyStore keyStore = KeyStore.getInstance("JKS");
InputStream keyStoreStream = new FileInputStream(Constantes.FICHEROP12);
keyStore.load(keyStoreStream, Constantes.PASSWORDP12);
SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(keyStore, Constantes.PASSWORDP12).build();
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(final String hostname, final SSLSession session) {
// TODO Apéndice de método generado automáticamente
return hostname.equals(Properties.getLexnetHostname());
}
};
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext, new String[] {"TLSv1.2", "TLSv1.1", "TLSv1"}, null,
hostnameVerifier);
HttpHost proxy = new HttpHost(Properties.getLexnetProxy(), 8080);
RequestConfig config = RequestConfig.custom()
.setProxy(proxy)
.build();
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", sslsf)
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.build();
PoolingHttpClientConnectionManager connectionManager =
new PoolingHttpClientConnectionManager(socketFactoryRegistry);
try (CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(config)
.setConnectionManager(connectionManager)
.build()) {
HttpPost httpPost = new HttpPost(Properties.getLexnetUrlEndpoint() + Constantes.OBTENERPENDIENTESGENERAL);
httpPost.setHeader("SOAPAction", "");
httpPost.setHeader("Content-Type", "text/xml; charset=UTF-8");
StringEntity stringEntity = new StringEntity(soapXml);
httpPost.setEntity(stringEntity);
xmlRespuesta = EntityUtils.toString(client.execute(httpPost).getEntity(), "UTF-8");
And on the line keyStore.load(keyStoreStream, Constantes.PASSWORDP12); error occurs:
[9/05/24 12:22:19:827 CEST] 000000c0 SystemErr R java.io.IOException: Invalid keystore format
[9/05/24 12:22:19:827 CEST] 000000c0 SystemErr R at com.ibm.crypto.provider.JavaKeyStore.engineLoad(Unknown Source)
[9/05/24 12:22:19:827 CEST] 000000c0 SystemErr R at java.security.KeyStore.load(KeyStore.java:1456)
It must be from the local Server since it works correctly in a shuttle class.
I would like to know how to configure an SSL certificate to Websphere Server v9. I have two certificates: one public (extension .cer) and another private (extension .p12 with his password).
Can somebody help me?
Thanks