Hello
I am trying to connect to a web API via https.
This sort of web service use an https connection.
I have to use 2 jks :
- jks1 containing a private key and a certificate
- jks2 containing only one certificate
both jks contents are necessary to connect to the API
I am trying to use using the pub.security.keystore:setKeyAndChain service
This service needs the folowing input parameters : keyStoreAlias and keyAlias
I can use this to include the jks1 in my ssl connection but how can I include the jks2 certificate ?
Additionnal note : I try to reproduce a java service into a flow service, may be the following code can help you to understand :
Properties file content :
safeUrl=The url I try to join
jksPath=/was/DOD_certificats/dodPublicCertificateCecurity.jks
jksPasswd=aaaaaa
keystorePath=/was/DOD_certificats/dodUserCertificateCecurity.jks
keystoreType=JKS
keystorePass=bbbbbb
java source :
// 1 Client certificate
FileInputStream kis = new FileInputStream(keystorePath);
KeyStore clientKey = KeyStore.getInstance(keystoreType);
clientKey.load(kis, keystorePass.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientKey, keystorePass.toCharArray());
// 2 web server certificate
InputStream ksstr = new FileInputStream(jksPath);
KeyStore ks = KeyStore.getInstance("jks");
ks.load(ksstr, jksPasswd.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
// SSL context
SSLContext sslctx = SSLContext.getInstance("TLS");
sslctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLSocketFactory ssf = sslctx.getSocketFactory();
Thanks in advance for your help