Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/src/node/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ describe('extractHostnamesFromSubjectAltName', () => {
['DNS:localhost, DNS:foo.localhost', ['localhost', 'foo.localhost']],
['DNS:*.localhost', ['vite.localhost']],
['DNS:[::1]', []], // [::1] is skipped
['DNS:*.192.168.0.152, DNS:192.168.0.152', ['192.168.0.152']], // *.192.168.0.152 is skipped
['othername:"foo,bar", DNS:localhost', ['localhost']], // handle quoted correctly
] as const

Expand Down
10 changes: 8 additions & 2 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs'
import os from 'node:os'
import net from 'node:net'
import path from 'node:path'
import { exec } from 'node:child_process'
import crypto from 'node:crypto'
Expand Down Expand Up @@ -1083,8 +1084,13 @@ export function extractHostnamesFromSubjectAltName(
}
remaining = remaining.slice(/* for , */ 1).trimStart()

// [::1] might be included but skip it as it's already included as a local address
if (name === 'DNS' && value !== '[::1]') {
if (
name === 'DNS' &&
// [::1] might be included but skip it as it's already included as a local address
value !== '[::1]' &&
// skip *.IPv4 addresses, which is invalid
!(value.startsWith('*.') && net.isIPv4(value.slice(2)))
) {
hostnames.push(value.replace('*', 'vite'))
}
}
Expand Down