1

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.

k.vincent
  • 3,743
  • 8
  • 37
  • 74
  • A _correct_ PEM file has the base64 broken into lines of 64 characters, except the last; see rfc7468 section 2 (or wiklipedia!). But some programs don't require or check this, so people don't agree on whether this is included in 'valid'. – dave_thompson_085 Nov 25 '19 at 12:20

0 Answers0