Regex to match PEM file headers according to OpenSSL pem.h
For each input pem string:
- check if it contains PEM header line
- check if it contains corresponding footer line
- join the in-between lines and try decoding it as base64
- return the matched
label, i.e.RSA PRIVATE KEYandtype, i.e.PRIVATE.
Match and return { label, type } or undefined:
- Property
labelcould be :PRIVATE KEYRSA PRIVATE KEYANY PRIVATE KEYENCRYPTED PRIVATE KEYPUBLIC KEY- ...
- Property
type:PRIVATEPUBLIC
Match and return { label, type } or undefined:
- Property
labelcould be:CERTIFICATETRUSTED CERTIFICATECERTIFICATE REQUESTNEW CERTIFICATE REQUESTX509 CRL
- Property
type:CERTIFICATEREQUESTCRL
Match only begin header and return { label, type } or undefined
Match only end footer and return { label, type } or undefined
Match only begin header and return { label } or undefined
Match only end footer and return { label } or undefined
Match and return the private key label or undefined.
Match and return the private key label or undefined.
Match and return the certificate label or undefined.
Match and return the certificate request label or undefined.
Match and return the CRL label or undefined.