-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
getCertificateInfoFromFile() function does not parse cert subject correctly.
| const regex = /(?:subject=)?[^=]+=\s+(\S+)/gim; |
It expects the CN as first item (by reading match[1]), which is not always the case.
Example:
openssl x509 -in cert.crt -subject -noout
Output: subject=C = DE, ST = State, L = City, O = MyOrg, OU = -, CN = *.example.com
When loading such a certificate in NPM it seems to work, but accessing the Proxy leads to a ERR_SSL_UNRECOGNIZED_NAME_ALERT error in the browser.
Fix: Make subject parsing regex more robust.
This one should be working:
const regex = /(?:subject=)?CN\s*=\s*(\S+)/gim;