Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java keyTool - append primary/secondary intermediate certificates to key store [closed]

I have already created a keystore (server.jks in the image) having imported the relevant key-pair.

keytool -importkeystore -srckeystore server.p12 -destkeystore server.jks -srcstoretype pkcs12

I need to append intermediate certificates to it using the java keytool.

Using KeyStore explorer tool on windows, I can append certificates following the right click context menu, just like in the attached image.

enter image description here

After adding the primary/intermediate certificates following the Append Certificate option, I can see it on the KeyStore explorer like a tree.

---primary intermediate certificate
     |---secondary intermediate certificate
           |---my server certificate  

I am very much interested in knowing how this can be done, using the 'Java KeyTool' on the (LINUX) command line.

Thank you in advance.

like image 590
Chathura Kulasinghe Avatar asked May 15 '14 18:05

Chathura Kulasinghe


1 Answers

This is more or less the same problem as in this question. You need to prepare a file representing the certificate chain, each certificate followed by the CA certificate that issued it.

-----BEGIN CERTIFICATE-----
MIICajCCAdOgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJVSzEa
....
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICkjCCAfugAwIBAgIJAKm5bDEMxZd7MA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNV
....
-----END CERTIFICATE-----

You may need to export your EEC (End Entity Certificate) from your keystore first (keytool -exportcert ...). Then, use the text editor of your choice (vi, emacs, gedit, ...) or cat to concatenate your EEC and the intermediate certificate(s) in order. Then import the resulting file into your keystore against the alias that contains your private key (keytool -importcert -alias ...).

like image 69
Bruno Avatar answered Oct 12 '22 21:10

Bruno