Docs
Type to search every article.
  1. Docs
  2. API

Origin certificates

3 min read Updated

On this page
  1. Read the certificate
  2. Create or reissue
  3. Revoke
  4. The zone's origin

A zone's origin certificate has an endpoint of its own, like its signing key, so listing zones never returns it: one call reads it, one creates or reissues it and is the only answer that carries its private key, and one revokes it. The zone object says only whether there is one, as ORIGIN_CERTIFICATE (1 or 0). What an origin certificate is and how to install one: Origin certificates.

Read the certificate#

HTTP
GET https://api.cachegenie.com/v1/cdn/{ZONE_ID}/origin-certificate
Shell
curl https://api.cachegenie.com/v1/cdn/AB12CD34E/origin-certificate \
  -H "Authorization: Bearer YOUR_API_KEY"
JSON
{
  "CODE": 200,
  "MESSAGE": "Origin Certificate Returned.",
  "DATA": {
    "CERTIFICATE":
      "-----BEGIN CERTIFICATE-----\nMIIDDzCCAfegAwIBAgIIQnB5...",
    "FINGERPRINT":
      "ad95d920ed8534d333cfefd23fb6368fa5bb2c3745ac191dbc2b06804dc3c88b",
    "CREATED": 1790395200,
    "EXPIRES": 253402262400
  }
}
  • CERTIFICATE (String): the certificate, PEM. The private key is never returned here.
  • FINGERPRINT (String): the SHA-256 of the whole certificate, 64 lower-case hexadecimal characters, which is what our servers compare.
  • CREATED (Integer): when it was made, Unix seconds.
  • EXPIRES (Integer): when it stops being valid, Unix seconds: 31 December 9999, the date the certificate standard sets aside for one that does not expire.

A zone with none answers 404 This zone has no origin certificate. Create one with POST.

Create or reissue#

HTTP
POST https://api.cachegenie.com/v1/cdn/{ZONE_ID}/origin-certificate

Makes a new certificate and key and returns both, with MESSAGE Origin Certificate Created., or Origin Certificate Reissued. when the zone had one, which our servers then stop trusting within about fifteen seconds. DATA is the object above with PRIVATE_KEY (String, PEM) beside the certificate. This is the only answer that carries the key, and it is not kept anywhere, so save it from this answer.

It takes one optional field, as a JSON body:

  • EXPECT_FINGERPRINT (String, optional): the FINGERPRINT of the certificate you expect the zone to have now, or an empty string for none. When it is sent, the certificate is created or reissued only if the zone's current one is that one, so a script never replaces a certificate it has not seen; otherwise nothing changes and the answer is 409. Upper or lower case. Left out, the call creates or reissues whatever the zone has.
Shell
curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E/origin-certificate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"EXPECT_FINGERPRINT": "ad95d920ed8534d333cfefd23fb6368fa5bb2c3745ac191dbc2b06804dc3c88b"}'
  • 400 EXPECT_FINGERPRINT must be a SHA-256 fingerprint in hex, or empty for none.: a value that is neither 64 hexadecimal characters nor empty.
  • 400 An origin certificate needs an https:// ORIGIN_URL, and an S3 bucket origin does not use one.: the zone's origin is http:// or a bucket. A tunnel zone can have one whatever its endpoint; it is checked on an https endpoint (see On a tunnel zone).
  • 400 An origin certificate names the zone's hostnames, and this zone has none yet. Add a hostname first.: the zone has no hostname.
  • 409 The zone's origin certificate has changed since you last looked. Reload to see it.: EXPECT_FINGERPRINT does not name the zone's current certificate. Read it with GET before deciding again.
  • 409 The zone's origin certificate changed while this request was made, so nothing was created. Retry.: another call created, reissued or revoked it at the same moment.
  • 500 Unable to create an origin certificate - Internal Server Error, please try again.: the certificate could not be made; nothing changed.
  • 500 Unable to save the origin certificate - Internal Server Error. Read it with GET: if a certificate is there, reissue it, because its key was not returned.: the certificate was made but its save did not answer.

Revoke#

HTTP
DELETE https://api.cachegenie.com/v1/cdn/{ZONE_ID}/origin-certificate

Our servers stop trusting the certificate within about fifteen seconds, and it is removed from the zone. The answer is Origin Certificate Revoked. with an empty DATA. A zone with none answers 404 This zone has no origin certificate.; one whose certificate changed during the call answers 409.

  • EXPECT_FINGERPRINT (String, optional): as for POST, sent as a JSON body: the certificate is revoked only if it is the one named, else the answer is 409 The zone's origin certificate has changed since you last looked. Reload to see it. and it stays. A value that is neither 64 hexadecimal characters nor empty is 400.

The zone's origin#

A zone with an origin certificate keeps an https:// ORIGIN_URL. Setting an http:// one through Zones answers 400 ORIGIN_URL has to be https:// while the zone has an origin certificate. Revoke it first with DELETE /v1/cdn/{ZONE_ID}/origin-certificate.