Import custom client certificate into java keystore
See also: Can Java keystore import a key pair generated by OpenSSL?
I have been provided with the following files to authenticate against the lean endpoint:
- cacert.pem
- local.crt
- local.key
My hardest part is trying to create a keystore that has a client certificate in it. The endpoint application has its own CA for authenticating client certificates. I'm honestly not sure what to include in the keystore (assuming client certificate and final end certificate), but for the rest of my life I can't get it to work.
Does anyone know how to import a client certificate into a keystore? Or, what do I need to do to get this to work? Thanks.
a source to share
The problem was with the keystore, this is how I finally got it working.
First of all, it should be noted that its not possible (as far as I know) to import private keys into a keystore using keytool ...
Knowing this, I converted local.crt and local.key to a .p12 file via openssl:
openssl pkcs12 -export -in local.crt -inkey local.key -out local.p12
Then I used a tool from IBM (keyman): http://www.alphaworks.ibm.com/tech/keyman/download
To import the CA certificate (cacert.crt) and then the .p12 file, then save it as a keystore.
Hope this helps someone!
a source to share