grantila / fetch-h2

HTTP/1+2 Fetch API client for Node.js
MIT License
336 stars 16 forks source link

SSL Certificate Error: Cannot read properties of undefined (reading 'match') #127

Open kopertop opened 3 months ago

kopertop commented 3 months ago

When a site has a very bad SSL Certificate, it can cause the following uncaught (and uncatchable) exception:

Cannot read properties of undefined (reading 'match')
node_modules/.pnpm/fetch-h2@3.0.2/node_modules/fetch-h2/dist/lib/san.js33:39
const regexes = [];
if (cert) {
    getNames(cert).forEach(name => {
        if (name.match(/.*\*.*\*.*/))
            throw new Error(`Invalid CN/subjectAltNames: ${name}`);
        if (name.includes("*"))
            regexes.push(new RegExp(makeRegex(name)));

Current example: https://kawvalleyeaglesday.com