Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google_public_ca_external_account_key returns base64 encoded mac key, should be base64url encoded #20801

Open
brokenjacobs opened this issue Dec 30, 2024 · 0 comments

Comments

@brokenjacobs
Copy link

brokenjacobs commented Dec 30, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Description

google_public_ca_external_account_key returns the created hmac key from the google api in a base64 encoded format. However to actually USE this key it must be base64URL encoded, not base64 encoded.
See here:
https://datatracker.ietf.org/doc/html/rfc4648#section-5
https://cert-manager.io/docs/configuration/acme/#external-account-bindings

I'm able to approximate the logic mentioned in the cert-manager documentation to use a key in terraform like this:

eab_hmac = replace(trim(google_public_ca_external_account_key.***.b64_mac_key, "="),"+","-")

But this isn't ideal. It would be better to return an additional attribute:

b64url_mac_key

with a base64url encoded version of the key, since that's what the ACME spec requires, and that is the only use for this key. These keys are ONLY used with the acme key protocol so it makes sense to return a key in the format used by that protocol.

New or Affected Resource(s)

  • google_public_ca_external_account_key

Potential Terraform Configuration

Previously:

resource "kubernetes_secret" "mysecret" {
  metadata {
    name      = "gcp-public-ca-acme"
    namespace = "cert-manager"
  }
  data = {
    eab_kid = google_public_ca_external_account_key.mykey.key_id
    # Approximate base64url encoding
    eab_hmac = replace(trim(google_public_ca_external_account_key.mykey.b64_mac_key, "="),"+","-")
  }
}

Desired:

resource "kubernetes_secret" "mysecret" {
  metadata {
    name      = "gcp-public-ca-acme"
    namespace = "cert-manager"
  }
  data = {
    eab_kid = google_public_ca_external_account_key.mykey.key_id
    eab_hmac = google_public_ca_external_account_key.mykey.b64url_mac_key
  }
}

References

No response

b/386817001

@github-actions github-actions bot added forward/review In review; remove label to forward service/publicca labels Dec 30, 2024
@zli82016 zli82016 removed the forward/review In review; remove label to forward label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants