Skip to content

Commit 973283b

Browse files
authoredFeb 13, 2025··
fix: ignore *.ipv4 address in cert (#19416)
1 parent 0f058a9 commit 973283b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎packages/vite/src/node/__tests__/utils.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ describe('extractHostnamesFromSubjectAltName', () => {
173173
['DNS:localhost, DNS:foo.localhost', ['localhost', 'foo.localhost']],
174174
['DNS:*.localhost', ['vite.localhost']],
175175
['DNS:[::1]', []], // [::1] is skipped
176+
['DNS:*.192.168.0.152, DNS:192.168.0.152', ['192.168.0.152']], // *.192.168.0.152 is skipped
176177
['othername:"foo,bar", DNS:localhost', ['localhost']], // handle quoted correctly
177178
] as const
178179

‎packages/vite/src/node/utils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'node:fs'
22
import os from 'node:os'
3+
import net from 'node:net'
34
import path from 'node:path'
45
import { exec } from 'node:child_process'
56
import crypto from 'node:crypto'
@@ -1083,8 +1084,13 @@ export function extractHostnamesFromSubjectAltName(
10831084
}
10841085
remaining = remaining.slice(/* for , */ 1).trimStart()
10851086

1086-
// [::1] might be included but skip it as it's already included as a local address
1087-
if (name === 'DNS' && value !== '[::1]') {
1087+
if (
1088+
name === 'DNS' &&
1089+
// [::1] might be included but skip it as it's already included as a local address
1090+
value !== '[::1]' &&
1091+
// skip *.IPv4 addresses, which is invalid
1092+
!(value.startsWith('*.') && net.isIPv4(value.slice(2)))
1093+
) {
10881094
hostnames.push(value.replace('*', 'vite'))
10891095
}
10901096
}

0 commit comments

Comments
 (0)
Please sign in to comment.