| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -338,7 +338,7 @@ int TLSContext::OnSelectAlpn(SSL* ssl, | |||
| 338 | 338 | in, | |
| 339 | 339 | inlen) == OPENSSL_NPN_NO_OVERLAP) { | |
| 340 | 340 | Debug(&tls_session.session(), "ALPN negotiation failed"); | |
| 341 | - return SSL_TLSEXT_ERR_NOACK; | ||
| 341 | + return SSL_TLSEXT_ERR_ALERT_FATAL; | ||
| 342 | 342 | } | |
| 343 | 343 | ||
| 344 | 344 | // ALPN negotiated successfully. *out/*outlen point to the selected | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,31 +2,39 @@ | |||
| 2 | 2 | ||
| 3 | 3 | // Test: ALPN mismatch causes connection failure. | |
| 4 | 4 | // The server offers 'quic-test' but the client requests 'nonexistent'. | |
| 5 | - // The handshake should fail. | ||
| 5 | + // The handshake should fail with a `no_application_protocol` alert. | ||
| 6 | + // | ||
| 7 | + // The QUIC transport error code for a CRYPTO_ERROR carrying a TLS alert is | ||
| 8 | + // 0x100 | <tls_alert>. For `no_application_protocol` (alert 120 / 0x78) this | ||
| 9 | + // is 0x178 == 376. ERR_QUIC_TRANSPORT_ERROR formats the wire code into its | ||
| 10 | + // message as a bigint, so we match `376n` to assert the specific alert was | ||
| 11 | + // sent rather than some other handshake failure. | ||
| 6 | 12 | ||
| 7 | 13 | import { hasQuic, skip, mustCall } from '../common/index.mjs'; | |
| 8 | 14 | import assert from 'node:assert'; | |
| 9 | 15 | ||
| 10 | - const { rejects, strictEqual } = assert; | ||
| 16 | + const { rejects, strictEqual, match } = assert; | ||
| 11 | 17 | ||
| 12 | 18 | if (!hasQuic) { | |
| 13 | 19 | skip('QUIC is not enabled'); | |
| 14 | 20 | } | |
| 15 | 21 | ||
| 16 | 22 | const { listen, connect } = await import('../common/quic.mjs'); | |
| 17 | 23 | ||
| 24 | + const expected = { | ||
| 25 | + code: 'ERR_QUIC_TRANSPORT_ERROR', | ||
| 26 | + message: /\b376n\b/, | ||
| 27 | + }; | ||
| 28 | + | ||
| 18 | 29 | const onerror = mustCall((err) => { | |
| 19 | 30 | strictEqual(err.code, 'ERR_QUIC_TRANSPORT_ERROR'); | |
| 31 | + match(err.message, /\b376n\b/); | ||
| 20 | 32 | }, 2); | |
| 21 | 33 | const transportParams = { maxIdleTimeout: 1 }; | |
| 22 | 34 | ||
| 23 | 35 | const serverEndpoint = await listen(mustCall(async (serverSession) => { | |
| 24 | - await rejects(serverSession.opened, { | ||
| 25 | - code: 'ERR_QUIC_TRANSPORT_ERROR', | ||
| 26 | - }); | ||
| 27 | - await rejects(serverSession.closed, { | ||
| 28 | - code: 'ERR_QUIC_TRANSPORT_ERROR', | ||
| 29 | - }); | ||
| 36 | + await rejects(serverSession.opened, expected); | ||
| 37 | + await rejects(serverSession.closed, expected); | ||
| 30 | 38 | }), { | |
| 31 | 39 | transportParams, | |
| 32 | 40 | onerror, | |
@@ -39,12 +47,8 @@ const clientSession = await connect(serverEndpoint.address, { | |||
| 39 | 47 | onerror, | |
| 40 | 48 | }); | |
| 41 | 49 | ||
| 42 | - await rejects(clientSession.opened, { | ||
| 43 | - code: 'ERR_QUIC_TRANSPORT_ERROR', | ||
| 44 | - }); | ||
| 50 | + await rejects(clientSession.opened, expected); | ||
| 45 | 51 | ||
| 46 | 52 | // The handshake should fail — opened may reject or never resolve. | |
| 47 | 53 | // The session should close with an error. | |
| 48 | - await rejects(clientSession.closed, { | ||
| 49 | - code: 'ERR_QUIC_TRANSPORT_ERROR', | ||
| 50 | - }); | ||
| 54 | + await rejects(clientSession.closed, expected); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments