type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Edit SSL Configuration
* Upload a new private key and/or PEM/CRT for the SSL certificate. Note: PATCHing a configuration for sni_custom certificates will result in a new resource id being returned, and the previous one being deleted.
*/
export async function main(
auth: Cloudflare,
identifier: string,
zone_identifier: string,
body: {
bundle_method?: "ubiquitous" | "optimal" | "force";
certificate?: string;
geo_restrictions?: {
label?: "us" | "eu" | "highest_security";
[k: string]: unknown;
};
policy?: string;
private_key?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_certificates/${identifier}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Edit SSL Configuration
* Upload a new private key and/or PEM/CRT for the SSL certificate. Note: PATCHing a configuration for sni_custom certificates will result in a new resource id being returned, and the previous one being deleted.
*/
export async function main(
auth: Cloudflare,
identifier: string,
zone_identifier: string,
body: {
bundle_method?: "ubiquitous" | "optimal" | "force";
certificate?: string;
geo_restrictions?: {
label?: "us" | "eu" | "highest_security";
[k: string]: unknown;
};
policy?: string;
private_key?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_certificates/${identifier}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 920 days ago