diff --git a/src/routes/api/internal/diagnostics/tls-handshake/+server.ts b/src/routes/api/internal/diagnostics/tls-handshake/+server.ts index 68de94e..551dab2 100644 --- a/src/routes/api/internal/diagnostics/tls-handshake/+server.ts +++ b/src/routes/api/internal/diagnostics/tls-handshake/+server.ts @@ -19,7 +19,6 @@ interface HandshakePhase { interface TLSHandshakeResponse { hostname: string; - servername?: string; port: number; success: boolean; totalTime: number; @@ -130,7 +129,6 @@ function performTLSHandshake(hostname: string, port: number, servername?: string const response: TLSHandshakeResponse = { hostname, - servername: servername || hostname, port, success: true, totalTime, diff --git a/src/routes/api/internal/diagnostics/tls/+server.ts b/src/routes/api/internal/diagnostics/tls/+server.ts index 1521f3e..4527d41 100644 --- a/src/routes/api/internal/diagnostics/tls/+server.ts +++ b/src/routes/api/internal/diagnostics/tls/+server.ts @@ -36,13 +36,14 @@ interface OCSPStaplingReq extends BaseReq { action: 'ocsp-stapling'; hostname: string; port?: number; + servername?: string; } interface CipherPresetsReq extends BaseReq { action: 'cipher-presets'; hostname: string; - servername?: string; port?: number; + servername?: string; } interface BannerReq extends BaseReq { @@ -313,12 +314,12 @@ async function probeALPN(host: string, port: number, protocols: string[], server } // OCSP Stapling check implementation -async function checkOCSPStapling(hostname: string, port: number = 443): Promise { +async function checkOCSPStapling(hostname: string, port: number = 443, servername?: string): Promise { return new Promise((resolve, reject) => { const options = { host: hostname, port, - servername: hostname, + servername: servername || hostname, requestOCSP: true, // SECURITY: rejectUnauthorized must be false to test OCSP stapling (see above) rejectUnauthorized: false, @@ -859,7 +860,7 @@ export const POST: RequestHandler = async ({ request }) => { } case 'ocsp-stapling': { - const { hostname, port = 443 } = body as OCSPStaplingReq; + const { hostname, port = 443, servername } = body as OCSPStaplingReq; // Validate hostname if (!hostname || typeof hostname !== 'string' || hostname.trim() === '') { @@ -871,7 +872,7 @@ export const POST: RequestHandler = async ({ request }) => { throw error(400, 'Invalid port number'); } - const result = await checkOCSPStapling(hostname, port); + const result = await checkOCSPStapling(hostname, port, servername); return json({ ...result, hostname, port }); } @@ -889,7 +890,7 @@ export const POST: RequestHandler = async ({ request }) => { } const result = await testCipherPresets(hostname, port, servername); - return json({ ...result, hostname, port, servername }); + return json({ ...result, hostname, port }); } case 'banner': { diff --git a/src/routes/diagnostics/tls/banner/+page.svelte b/src/routes/diagnostics/tls/banner/+page.svelte index 0f170fc..a0c68ee 100644 --- a/src/routes/diagnostics/tls/banner/+page.svelte +++ b/src/routes/diagnostics/tls/banner/+page.svelte @@ -7,8 +7,6 @@ let host = $state(''); let port = $state(null); - let servername = $state(''); - let useCustomServername = $state(false); let service = $state('custom'); const diagnosticState = useDiagnosticState(); @@ -81,7 +79,6 @@ body: JSON.stringify({ action: 'banner', host: host.trim(), - servername: useCustomServername && servername ? servername.trim() : undefined, port: port, }), }); @@ -213,45 +210,15 @@ -
-
- - {#if useCustomServername} - { - examples.clear(); - if (isInputValid()) grabBanner(); - }} - /> - {/if} -
-
- -
- -
+ diff --git a/src/routes/diagnostics/tls/cipher-presets/+page.svelte b/src/routes/diagnostics/tls/cipher-presets/+page.svelte index e74bcc3..6623150 100644 --- a/src/routes/diagnostics/tls/cipher-presets/+page.svelte +++ b/src/routes/diagnostics/tls/cipher-presets/+page.svelte @@ -3,6 +3,7 @@ import { useDiagnosticState, useExamples } from '$lib/composables'; import ExamplesCard from '$lib/components/common/ExamplesCard.svelte'; import ErrorCard from '$lib/components/common/ErrorCard.svelte'; + import { tooltip } from '$lib/actions/tooltip.js'; import '../../../../styles/diagnostics-pages.scss'; let hostname = $state('example.com'); @@ -16,17 +17,6 @@ { host: 'google.com', port: '443', description: 'Google cipher support' }, ]; const examples = useExamples(examplesList); - - // Reactive validation - const isInputValid = $derived(() => { - const trimmedHost = host.trim(); - if (!trimmedHost) return false; - if (port === null || port < 1 || port > 65535) return false; - // Basic hostname/IP validation - const hostPattern = - /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|^\[?[a-fA-F0-9:]+\]?$/; - return hostPattern.test(trimmedHost); - }); async function testCiphers() { if (!hostname?.trim()) { @@ -43,8 +33,8 @@ body: JSON.stringify({ action: 'cipher-presets', hostname: hostname.trim().toLowerCase(), - servername: useCustomServername && servername ? servername.trim() : undefined, port: parseInt(port) || 443, + servername: useCustomServername && servername ? servername.trim() : undefined, }), }); @@ -63,6 +53,8 @@ function loadExample(example: (typeof examplesList)[0], index: number) { hostname = example.host; port = example.port; + servername = ''; + useCustomServername = false; examples.select(index); testCiphers(); } @@ -108,72 +100,56 @@

Cipher Presets Configuration

-
-
- -
- examples.clear()} - onkeydown={(e) => e.key === 'Enter' && testCiphers()} - class="flex-grow" - /> - examples.clear()} - onkeydown={(e) => e.key === 'Enter' && testCiphers()} - class="port-input" - /> -
+
+ +
+ examples.clear()} + onkeydown={(e) => e.key === 'Enter' && testCiphers()} + class="flex-grow" + /> + examples.clear()} + onkeydown={(e) => e.key === 'Enter' && testCiphers()} + class="port-input" + /> +
- -
-
- - {#if useCustomServername} - { - examples.clear(); - if (isInputValid()) testCiphers(); - }} - /> - {/if} -
-
- -
- +
+ + {#if useCustomServername} + examples.clear()} + onkeydown={(e) => e.key === 'Enter' && testCiphers()} + /> + {/if}
diff --git a/src/routes/diagnostics/tls/handshake-analyzer/+page.svelte b/src/routes/diagnostics/tls/handshake-analyzer/+page.svelte index 0493590..09159fa 100644 --- a/src/routes/diagnostics/tls/handshake-analyzer/+page.svelte +++ b/src/routes/diagnostics/tls/handshake-analyzer/+page.svelte @@ -4,6 +4,7 @@ import ExamplesCard from '$lib/components/common/ExamplesCard.svelte'; import ErrorCard from '$lib/components/common/ErrorCard.svelte'; import { tlsHandshakeContent } from '$lib/content/tls-handshake'; + import { tooltip } from '$lib/actions/tooltip.js'; import '../../../../styles/diagnostics-pages.scss'; interface HandshakePhase { @@ -47,17 +48,6 @@ { hostname: 'zoom.us', port: 443, description: 'Zoom' }, ]; const examples = useExamples(examplesList); - - // Reactive validation - const isInputValid = $derived(() => { - const trimmedHost = host.trim(); - if (!trimmedHost) return false; - if (port === null || port < 1 || port > 65535) return false; - // Basic hostname/IP validation - const hostPattern = - /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|^\[?[a-fA-F0-9:]+\]?$/; - return hostPattern.test(trimmedHost); - }); async function analyzeHandshake() { diagnosticState.startOperation(); @@ -67,9 +57,9 @@ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - hostname: hostname.trim(), + hostname: hostname.trim(), port, - servername: useCustomServername && servername ? servername.trim() : undefined + servername: useCustomServername && servername ? servername.trim() : undefined, }), }); @@ -87,6 +77,8 @@ function loadExample(example: (typeof examplesList)[0], index: number) { hostname = example.hostname; port = example.port; + servername = ''; + useCustomServername = false; examples.select(index); analyzeHandshake(); } @@ -141,8 +133,8 @@

Handshake Analysis

-
-
+
+
Port
-
- -
-
- - {#if useCustomServername} - { - examples.clear(); - if (isInputValid()) analyzeHandshake(); - }} - /> - {/if} -
-
- -
+
+ + {#if useCustomServername} + { + examples.clear(); + if (hostname.trim()) analyzeHandshake(); + }} + /> + {/if} +
@@ -390,6 +369,36 @@