Working With PEM Content Home » CentOS » Working With PEM Content September 9, 2015 Alice Wonder CentOS 2 Comments Hi, If I need to script some management of text files with PEM content, are there already some tools that exist that do this safely? e.g. somecert.pem that might contain —–BEGIN CERTIFICATE—
September 9, 2015 Alice Wonder CentOS 2 Comments Hi, If I need to script some management of text files with PEM content, are there already some tools that exist that do this safely? e.g. somecert.pem that might contain —–BEGIN CERTIFICATE—
cat ${CERT} |sed ‘/^—–BEGIN DH PARAMETERS—–$/,/^—–END DH PARAMETERS—–$/d’ > ${TMPFILE} (one line) seems to work every time as long as it is well formed.
“openssl” provides commands that should be able to process the PEM components in-place. For instance, if you want to extract the certificate, only, from a PEM file, you can: openssl x509 -in somecert.pem -out cert-only.pem …and for the private key: openssl rsa -in somecert.pem -out key-only.pem
2 thoughts on - Working With PEM Content
cat ${CERT} |sed ‘/^—–BEGIN DH PARAMETERS—–$/,/^—–END DH
PARAMETERS—–$/d’ > ${TMPFILE}
(one line) seems to work every time as long as it is well formed.
“openssl” provides commands that should be able to process the PEM
components in-place.
For instance, if you want to extract the certificate, only, from a PEM
file, you can:
openssl x509 -in somecert.pem -out cert-only.pem
…and for the private key:
openssl rsa -in somecert.pem -out key-only.pem