I have two files:
mycer.cer
mykey.key
I need to create a SslContext
to connect to another server via SSL using Java.
I'm trying to find out how I can create the SslContext
object directly from those files.
This post may be duplicated, but I tried to find a clear explanation with an example to create the SslContext
, but didn't find something clear.
You can use OpenSSL to create a private key and a certificate signing request (CSR) that can be transformed into a certificate after it is signed by a certificate authority (CA).
You cannot generate private key from public key but you can generate public key from the private key using puttygen. As @alfasin mentioned if you could generate the private key from public key then RSA would be useless and this would make you vulnerable to attack.
Get a certificate in p12 format, as far I know you can not use cert file, there are utilities to do that (like openssl) or the source (from where you generated downloaded the certificate) can give you a p12 format.
openssl pkcs12 -export -in mycer.crt -inkey mykey.key -out mycer.p12 -name "mycer"
And then check the below url, it should contain the information you want.
Java HTTPS client certificate authentication
Hopefully it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With