Ask: Cloudflare api generate origin cert

Hi All,

i’d like to try using api token within my ansible playbook for generate origin certificate & i’m wondering if i can generate the origin certificate without the needs to have CSR in the api variables ? as from webpanel in Cloudflare i can generate private key & CSR with Cloudflare
below are the task playbook i currently test please feel free to cmiiw

    - name: uri module
      ansible.builtin.uri:
        url: "https://api.cloudflare.com/client/v4/certificates"
        method: POST
        headers:
          Content-Type: application/json
          Authorization: "Bearer <token>"
        body_format: json
        body:
           hostnames: "domain.com"
          requesprted_validity: 5475
          request_type: "origin-ecc"
          csr: ""

Many thanks & appreciate your help

The API does require a CSR.

https://api.cloudflare.com/#origin-ca-create-certificate

Many thanks Sandro,
i tried to check on my Cloudflare account and based on Cloudflare doc to generate CSR should go

  • SSL / TLS → Edge certificates.
  • On Certificate Signing Request (CSR), click Generate.

But some how i dont see a button / menu for "Certificate Signing Request ( CSR) on that menu, perhaps i misunderstand something related with CSR

You wouldn’t generate the CSR on Cloudflare, but with any other regular tool, for example OpenSSL.

1 Like

Many thanks Sandro, sorry if perhaps you know why when use Cloudflare api we need to use the csr instead unlike when use Cloudflare web based we have 2 options when we want to generate origin server (either automatically from Cloudflare or using csr by input our csr key )

Perhaps are there any advantages when we create origin cert with csr instead automatically from Cloudflare ?

The only advantage with a CSR is that you keep the key on your side, whereas when you create it via the UI, Cloudflare could keep it in theory.

If you want to call the API, just pass along your CSR and the certificate should be issued just fine.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.