I wanted to do the same, but apparently this is only possible if you import the key:
There are two types of records - key records and trusted certificate records, and only a key record can contain a "chain" of certificates attached to it. Trusted certificate entries are all certificate entries.
( https://www.java.net/node/674524#comment-709695 )
I even tried converting to PKCS # 7 at the beginning , but it didn’t work due to the above reason or because my version of keytool was too old.
Therefore, at first it was necessary to split the file into separate certificates:
cat certchain.pem | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > ("cert" n ".pem")}'
( https://serverfault.com/q/391396/58568 )
Then import each separately.
bmaupin
source share