I do have an input field within angular app (v8) where I upload a pem certificate (.pem extension).
I would like to check if the uploaded file is valid or not. Using a RegExp is an option but it's a kind of not 100% sure.
My question, is if there is any library (maybe via npm) which validate a PEM certificate and throws an error on the fly if not valid, otherwise passes, or if there is a better option/concept for that?
The certificate should start:
----BEGIN CERTIFICATE----
followed by a base64 encoded string and ends with:
----END CERTIFICATE----
I have been searching on SO and found some useful hints:
Validate certificate in DER format
Manually verify SSL Self Signed certificate signature
but as said, a library would be more efficient.