mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
BREAKING: add Deno.CreateHttpClientOptions.{cert,key}
(#22280)
This change deprecates `Deno.CreateHttpClientOptions.{certChain,privateKey}` in favour of `Deno.CreateHttpClientOptions.{cert,key}`. Closes #22278 Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
08071f9561
commit
3a243c8272
3 changed files with 17 additions and 17 deletions
8
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
8
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -896,10 +896,10 @@ declare namespace Deno {
|
|||
caCerts?: string[];
|
||||
/** A HTTP proxy to use for new connections. */
|
||||
proxy?: Proxy;
|
||||
/** PEM formatted client certificate chain. */
|
||||
certChain?: string;
|
||||
/** PEM formatted (RSA or PKCS8) private key of client certificate. */
|
||||
privateKey?: string;
|
||||
/** Server private key in PEM format. */
|
||||
cert?: string;
|
||||
/** Cert chain in PEM format. */
|
||||
key?: string;
|
||||
/** Sets the maximum numer of idle connections per host allowed in the pool. */
|
||||
poolMaxIdlePerHost?: number;
|
||||
/** Set an optional timeout for idle sockets being kept-alive.
|
||||
|
|
|
@ -794,8 +794,8 @@ impl HttpClientResource {
|
|||
pub struct CreateHttpClientArgs {
|
||||
ca_certs: Vec<String>,
|
||||
proxy: Option<Proxy>,
|
||||
cert_chain: Option<String>,
|
||||
private_key: Option<String>,
|
||||
cert: Option<String>,
|
||||
key: Option<String>,
|
||||
pool_max_idle_per_host: Option<usize>,
|
||||
pool_idle_timeout: Option<serde_json::Value>,
|
||||
#[serde(default = "default_true")]
|
||||
|
@ -826,12 +826,12 @@ where
|
|||
}
|
||||
|
||||
let client_cert_chain_and_key = {
|
||||
if args.cert_chain.is_some() || args.private_key.is_some() {
|
||||
if args.cert.is_some() || args.key.is_some() {
|
||||
let cert_chain = args
|
||||
.cert_chain
|
||||
.cert
|
||||
.ok_or_else(|| type_error("No certificate chain provided"))?;
|
||||
let private_key = args
|
||||
.private_key
|
||||
.key
|
||||
.ok_or_else(|| type_error("No private key provided"))?;
|
||||
|
||||
Some((cert_chain, private_key))
|
||||
|
|
|
@ -1333,8 +1333,8 @@ Deno.test(
|
|||
async function fetchClientCertWrongPrivateKey(): Promise<void> {
|
||||
await assertRejects(async () => {
|
||||
const client = Deno.createHttpClient({
|
||||
certChain: "bad data",
|
||||
privateKey: await Deno.readTextFile(
|
||||
cert: "bad data",
|
||||
key: await Deno.readTextFile(
|
||||
"tests/testdata/tls/localhost.key",
|
||||
),
|
||||
});
|
||||
|
@ -1350,10 +1350,10 @@ Deno.test(
|
|||
async function fetchClientCertBadPrivateKey(): Promise<void> {
|
||||
await assertRejects(async () => {
|
||||
const client = Deno.createHttpClient({
|
||||
certChain: await Deno.readTextFile(
|
||||
cert: await Deno.readTextFile(
|
||||
"tests/testdata/tls/localhost.crt",
|
||||
),
|
||||
privateKey: "bad data",
|
||||
key: "bad data",
|
||||
});
|
||||
await fetch("https://localhost:5552/assets/fixture.json", {
|
||||
client,
|
||||
|
@ -1367,10 +1367,10 @@ Deno.test(
|
|||
async function fetchClientCertNotPrivateKey(): Promise<void> {
|
||||
await assertRejects(async () => {
|
||||
const client = Deno.createHttpClient({
|
||||
certChain: await Deno.readTextFile(
|
||||
cert: await Deno.readTextFile(
|
||||
"tests/testdata/tls/localhost.crt",
|
||||
),
|
||||
privateKey: "",
|
||||
key: "",
|
||||
});
|
||||
await fetch("https://localhost:5552/assets/fixture.json", {
|
||||
client,
|
||||
|
@ -1387,10 +1387,10 @@ Deno.test(
|
|||
const data = "Hello World";
|
||||
const caCert = await Deno.readTextFile("tests/testdata/tls/RootCA.crt");
|
||||
const client = Deno.createHttpClient({
|
||||
certChain: await Deno.readTextFile(
|
||||
cert: await Deno.readTextFile(
|
||||
"tests/testdata/tls/localhost.crt",
|
||||
),
|
||||
privateKey: await Deno.readTextFile(
|
||||
key: await Deno.readTextFile(
|
||||
"tests/testdata/tls/localhost.key",
|
||||
),
|
||||
caCerts: [caCert],
|
||||
|
|
Loading…
Reference in a new issue