snowdrop / godaddy-webhook

Cert Manager Godaddy Webhook performing ACME challenge using DNS record
Apache License 2.0
74 stars 63 forks source link

Challenge CR reports an Unexpected HTTP status: 401 from GoDaddy #31

Closed cmoulliard closed 1 year ago

cmoulliard commented 1 year ago

Issue

When we create a Certificate CR to request to get from Godaddy a certificate using DNS-01, the challenge created by the certificate manager to issue a ACME reqyuest with Godaddy returns the following error

reason: 'Unable to check the TXT record: ### Unexpected HTTP status: 401'

Example of CR

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: snowdrop-dev
  labels:
    app: ca-cert
  namespace: snowdrop-site
spec:
  authorizationURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/265604611626
  dnsName: snowdrop.dev
  issuerRef:
    kind: Issuer
    name: letsencrypt-prod-snowdrop-dev
  key: soOO...0DywA
  solver:
    dns01:
      webhook:
        config:
          apiKeySecretRef:
            key: token
            name: godaddy-api-key
          production: true
          ttl: 600
        groupName: acme.mycompany.com
        solverName: godaddy
    selector:
      dnsNames:
      - snowdrop.dev
      - '*.apps.ocp.snowdrop.dev'
  token: -0odX-rE5T...NCrLA
  type: DNS-01
  url: https://acme-v02.api.letsencrypt.org/acme/chall-v3/265604611626/eKNU3Q
  wildcard: false
status:
  presented: false
  processing: true
  reason: 'Unable to check the TXT record: ### Unexpected HTTP status: 401'
  state: pending

The problem is not related to the Godaddy API and Secret keys used as we can get a certificate/keys using Lego tool

GODADDY_API_KEY=dLD...GtDHq \
GODADDY_API_SECRET=jL44...GgTps \
lego --email cmoulliard@redhat.com --dns godaddy --domains console2-openshift-console.apps.ocp.snowdrop.dev run
2023/09/19 08:57:17 No key found for account cmoulliard@redhat.com. Generating a P256 key.
2023/09/19 08:57:17 Saved key to /Users/cmoullia/temp/lego/.lego/accounts/acme-v02.api.letsencrypt.org/cmoulliard@redhat.com/keys/cmoulliard@redhat.com.key
2023/09/19 08:57:18 Please review the TOS at https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf
Do you accept the TOS? Y/n
Y
2023/09/19 08:57:27 [INFO] acme: Registering account for cmoulliard@redhat.com
!!!! HEADS UP !!!!

Your account credentials have been saved in your Let's Encrypt
configuration directory at "/Users/cmoullia/temp/lego/.lego/accounts".

You should make a secure backup of this folder now. This
configuration directory will also contain certificates and
private keys obtained from Let's Encrypt so making regular
backups of this folder is ideal.
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Obtaining bundled SAN certificate
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/265836647926
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Could not find solver for: tls-alpn-01
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Could not find solver for: http-01
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: use dns-01 solver
2023/09/19 08:57:27 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Preparing to solve DNS-01
2023/09/19 08:57:29 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Trying to solve DNS-01
2023/09/19 08:57:29 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Checking DNS record propagation using [10.38.5.26:53 10.11.5.19:53]
2023/09/19 08:57:31 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2023/09/19 08:57:31 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:33 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:36 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:38 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:40 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:42 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Waiting for DNS record propagation.
2023/09/19 08:57:48 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] The server validated our request
2023/09/19 08:57:48 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Cleaning DNS-01 challenge
2023/09/19 08:57:49 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] acme: Validations succeeded; requesting certificates
2023/09/19 08:57:50 [INFO] [console2-openshift-console.apps.ocp.snowdrop.dev] Server responded with a certificate.

Notice: I suspect a Cert Manager + LetsEncrypt DNS-01 ACME challenge issue OR a Godaddy Webhook issue . to be investigated

cmoulliard commented 1 year ago

Problem fixed after removing from the k8s secret the non needed text token: sso-key api:secret -> token: api:secret part of the GoDaddy token