I have a Java application that is trying to connect to C++ server using an SSLSocket connection.
I have all the details necessary for creating the SSLSocket object except... I have no idea how to load keys and certs into my KeyStore object.
I have 2 certs (CA and Client) and a Client Private Key - ALL of which are in PEM file format.
Any ideas how I would go about adding the PEM certs & key to my KeyStore? I think I'll need to first convert from PEM format to some format that KeyTool will be able to read and then run KeyTool....
Any info would be appreciated!
C++ Server Encryption Details (OpenSSL)
Encryption method used - TLSv1
Using self-signed certificates
Using both server and clients certificates
Private keys of server and clients certificates are encrypted with a pass phrase for extra security
Client Socket Connection Code:
Socket mySocket = null;
SSLSocketFactory sslFactory = null;
SSLContext sslCtx = SSLContext.getInstance( "TLS" ); //TLS?
KeyManagerFactory kMF = KeyManagerFactory.getInstance( "SunX509" ); //"SunX509"??
KeyStore kS = KeyStore.getInstance( "JKS") ; //"JKS"??
//Hard-coded password for decrypting Client Key
char[] passWord= "myPassword".toCharArray();
kS .load(new FileInputStream("InputFile"), passWord= ); //"InputFile" from PEM Files?
kMF.init(kS, passWord);
TrustManagerFactory tMF = TrustManagerFactory.getInstance("SunX509");
tMF.init( ks );
sslCtx.init(tMF.getKeyManagers(), tMF.getTrustManagers(), null);
sslFactory = sslCtx.getSocketFactory();
mySocket = factory.createSocket(inetAddress, commandPort);