0

Revoke Certificate

by
Published Nov 16, 2023

Revoke an existing Origin CA certificate by its serial number. Use your Origin CA Key as your User Service Key when calling this endpoint ([see above](#requests)).

Script cloudflare Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 403 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Revoke Certificate
8
 * Revoke an existing Origin CA certificate by its serial number. Use your Origin CA Key as your User Service Key when calling this endpoint ([see above](#requests)).
9
 */
10
export async function main(auth: Cloudflare, identifier: string) {
11
  const url = new URL(
12
    `https://api.cloudflare.com/client/v4/certificates/${identifier}`
13
  );
14

15
  const response = await fetch(url, {
16
    method: "DELETE",
17
    headers: {
18
      "X-AUTH-EMAIL": auth.email,
19
      "X-AUTH-KEY": auth.key,
20
      "Content-Type": "application/json",
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31