In the case of Strongswan, you can display what it calls keyid using its command line utilities. The key point of keyid is that it can be used to identify the actual public key contained in the certificate so that the certificate can change, but by checking keyid, you can check if the key has changed or not.
The pki command will list the keywords for the X.509 certificate as follows (where subjectPublicKeyInfo hash is keyid ):
pki --keyid --in cert.pem --type x509
Or for the RSA private key:
pki --keyid --in key.pem
The second ipsec , which can be used to display all the certificates (and config) installed in the /etc/ipsec.d subdirectories (this command will list the certificates and their corresponding keyid that match their subjectPublicKeyInfo hash listed by the pki command):
ipsec listall
You can also use openssl to generate Strongswan ideas for keyid , which is basically SHA1 of the RSA public key ( sed script just translates '----- BEGIN PUBLIC KEY -----' and END) [Bug after Miki's comment]:
openssl x509 -in cert.pem -noout -pubkey | sed 's/--.*$//g' | base64 --decode | sha1sum
Pierz
source share