Link to home
Start Free TrialLog in
Avatar of Sathish David  Kumar N
Sathish David Kumar NFlag for India

asked on

How to convert a PEM-formatted String to a java.security.cert

"certfication": "-----BEGIN CERTIFICATE-----  certificate content --END CERTIFICATE-----"
Iam getting as string i need to convert this as java certificate

I tried CertificateFactory but notable create correctly ?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Something like

openssl x509 -outform der -in certificate.pem -out certificate.der

Open in new window


Then import it into the keystore:

keytool -import -alias your-alias -keystore cacerts -file certificate.der

Open in new window

Avatar of Sathish David  Kumar N

ASKER

how we will do it via programmatically ? 
Probably simplest to execute the above with Runtime.exec
is there any other (alternative) command for  openssl
Not that i know of
my system dont have openssl
where we can download that

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial