I have a combined .pem file which looks like this:
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
I think this is a combination of ssl, key and ca. I need to convert this to truststore.jks and keystore.jks for my service.
openssl pkcs12 -export -out cert.pkcs12 -in cert
keytool -importcert -v -trustcacerts -alias eb-srv -file cert.pkcs12 -keystore truststore.jks
However this throws:
keytool error: java.lang.Exception: Input not an X.509 certificate
java.lang.Exception: Input not an X.509 certificate
at sun.security.tools.keytool.Main.addTrustedCert(Main.java:2861)
at sun.security.tools.keytool.Main.doCommands(Main.java:1050)
at sun.security.tools.keytool.Main.run(Main.java:366)
at sun.security.tools.keytool.Main.main(Main.java:359)
Same happens if I try:
openssl x509 -outform der -in cert -out cert.der
keytool -import -alias eb-srv -keystore cacerts -file cert.der