mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(ext/net): check for TLS using undefined rather than using ReflectHas (#23538)
Fixes #23537
This commit is contained in:
parent
eed2598e6c
commit
da70608700
2 changed files with 35 additions and 5 deletions
|
@ -15,7 +15,6 @@ import {
|
||||||
const {
|
const {
|
||||||
Number,
|
Number,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ReflectHas,
|
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
@ -134,10 +133,10 @@ class TlsListener extends Listener {
|
||||||
* interfaces.
|
* interfaces.
|
||||||
*/
|
*/
|
||||||
function hasTlsKeyPairOptions(options) {
|
function hasTlsKeyPairOptions(options) {
|
||||||
return (ReflectHas(options, "cert") || ReflectHas(options, "key") ||
|
return (options.cert !== undefined || options.key !== undefined ||
|
||||||
ReflectHas(options, "certFile") ||
|
options.certFile !== undefined ||
|
||||||
ReflectHas(options, "keyFile") || ReflectHas(options, "privateKey") ||
|
options.keyFile !== undefined || options.privateKey !== undefined ||
|
||||||
ReflectHas(options, "certChain"));
|
options.certChain !== undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2889,6 +2889,37 @@ Deno.test(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Regression test for https://github.com/denoland/deno/issues/23537
|
||||||
|
Deno.test(
|
||||||
|
{ permissions: { read: true, net: true } },
|
||||||
|
async function httpServerUndefinedCert() {
|
||||||
|
const ac = new AbortController();
|
||||||
|
const { promise, resolve } = Promise.withResolvers<void>();
|
||||||
|
const hostname = "127.0.0.1";
|
||||||
|
|
||||||
|
const server = Deno.serve({
|
||||||
|
handler: () => new Response("Hello World"),
|
||||||
|
hostname,
|
||||||
|
port: servePort,
|
||||||
|
signal: ac.signal,
|
||||||
|
onListen: onListen(resolve),
|
||||||
|
onError: createOnErrorCb(ac),
|
||||||
|
// Undefined should be equivalent to missing
|
||||||
|
cert: undefined,
|
||||||
|
key: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
await promise;
|
||||||
|
const resp = await fetch(`http://localhost:${servePort}/`);
|
||||||
|
|
||||||
|
const respBody = await resp.text();
|
||||||
|
assertEquals("Hello World", respBody);
|
||||||
|
|
||||||
|
ac.abort();
|
||||||
|
await server.finished;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true, net: true } },
|
{ permissions: { read: true, net: true } },
|
||||||
async function httpServerWithTls() {
|
async function httpServerWithTls() {
|
||||||
|
|
Loading…
Reference in a new issue