Closed arekm closed 3 weeks ago
If a .pem file contains multiple certificates and also private certificates like:
-----BEGIN CERTIFICATE----- MIIDX... ... -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIDX... ... -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIDXT... ... -----END CERTIFICATE----- -----BEGIN PRIVATE KEY----- MIIE... ... -----END PRIVATE KEY-----
then lesspipe (looking at 2.14) makes that only first certificate is being displayed thus hiding the fact that there are other certificates in the file. That's very misleading.
Some other solution would be welcome like
cat a.pem | awk 'BEGIN {RS=""; FS="\n"} { for (i=1; i<=NF; i++) { if ($i ~ /-----BEGIN CERTIFICATE-----/) { print $0 | "openssl x509 -text -noout" } if ($i ~ /-----BEGIN PRIVATE KEY-----/ || $i ~ /-----BEGIN RSA PRIVATE KEY-----/) { print $0 | "openssl pkey -text -noout" } } }'
if that can be integrated into the way lesspipe is made.
I solved it differently. openssl has a command storeutl precisely for that. Did not know that up to now.
If a .pem file contains multiple certificates and also private certificates like:
then lesspipe (looking at 2.14) makes that only first certificate is being displayed thus hiding the fact that there are other certificates in the file. That's very misleading.
Some other solution would be welcome like
if that can be integrated into the way lesspipe is made.