Skip to content

publicca: add mac_key, fix and deprecate b64url_mac_key#16198

Merged
slevenick merged 1 commit intoGoogleCloudPlatform:mainfrom
champtar:publicca_mac_key
Feb 2, 2026
Merged

publicca: add mac_key, fix and deprecate b64url_mac_key#16198
slevenick merged 1 commit intoGoogleCloudPlatform:mainfrom
champtar:publicca_mac_key

Conversation

@champtar
Copy link
Copy Markdown
Contributor

@champtar champtar commented Jan 23, 2026

https://docs.cloud.google.com/certificate-manager/docs/reference/public-ca/rest/v1/projects.locations.externalAccountKeys#ExternalAccountKey

b64MacKey is defined as

string (bytes format)
Output only. Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService when the ExternalAccountKey is created

A base64-encoded string.

So the content is a 'Base64-URL-encoded HS256 key', and it's base64url encoded a second time as it's a string in 'bytes format'

This can be confirmed by using the CLI:

gcloud publicca external-account-keys create --log-http

we see that the CLI base64 decode the content for us.

b64_mac_key is the raw output from the API: URLEncoding(RawURLEncoding(binary key))
b64url_mac_key is the same but unpadded: RawURLEncoding(RawURLEncoding(binary key))

We introduce mac_key to get the same format as the CLI: RawURLEncoding(binary key)

Fixes: hashicorp/terraform-provider-google#25799
Fixes: hashicorp/terraform-provider-google#25646

Release Note Template for Downstream PRs (will be copied)

publicca: added `mac_key` to `google_public_ca_external_account_key`
publicca: fixed `b64url_mac_key` sometimes being empty in `google_public_ca_external_account_key`
publicca: deprecated `b64url_mac_key` on `google_public_ca_external_account_key`, use `mac_key` instead

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Jan 23, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 23, 2026
@github-actions github-actions Bot requested a review from slevenick January 23, 2026 03:11
@github-actions
Copy link
Copy Markdown

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added service/publicca and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Jan 23, 2026
@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 3 files changed, 39 insertions(+), 9 deletions(-))
google-beta provider: Diff ( 3 files changed, 39 insertions(+), 9 deletions(-))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 1
Passed tests: 1
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • publicca

🟢 All tests passed!

View the build log

@github-actions
Copy link
Copy Markdown

@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

type: String
description: |
Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService
Double Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double?

type: String
description: |
Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService
Double Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this supposed to mean?

Copy link
Copy Markdown
Contributor Author

@champtar champtar Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means base64(base64(binary key)), I'm totally open to better suggestions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. I guess I would say something like:

Double Base64-URL-encoded HS256 key. To read the contents of this key you must base64 decode the value twice. It is generated....

Copy link
Copy Markdown
Contributor Author

@champtar champtar Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you pass around the base64(binary key) to software like cert-manager, so you only need to base64 decode once here, what do you think of Doubly Base64-URL-encoded HS256 key ('base64(base64(binary key))'). It is generated by the ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slevenick I just pushed Doubly Base64-URL-encoded HS256 key ('base64(base64(binary key))')., if you prefer your version that's also fine with me, just tell me

https://docs.cloud.google.com/certificate-manager/docs/reference/public-ca/rest/v1/projects.locations.externalAccountKeys#ExternalAccountKey

b64MacKey is defined as

    string (bytes format)
    Output only. Base64-URL-encoded HS256 key. It is generated by the PublicCertificateAuthorityService when the ExternalAccountKey is created

    A base64-encoded string.

So the content is a 'Base64-URL-encoded HS256 key', and it's base64url encoded a second time as it's a string in 'bytes format'

This can be confirmed by using the CLI:

    gcloud publicca external-account-keys create --log-http

we see that the CLI base64 decode the content for us.

b64_mac_key is the raw output from the API: URLEncoding(RawURLEncoding(binary key))
b64url_mac_key is the same but unpadded: RawURLEncoding(RawURLEncoding(binary key))

We introduce mac_key to get the same format as the CLI: RawURLEncoding(binary key)
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 28, 2026
@github-actions github-actions Bot requested a review from slevenick January 28, 2026 20:41
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 28, 2026
@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 3 files changed, 39 insertions(+), 9 deletions(-))
google-beta provider: Diff ( 3 files changed, 39 insertions(+), 9 deletions(-))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 1
Passed tests: 1
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • publicca

🟢 All tests passed!

View the build log

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@slevenick slevenick added this pull request to the merge queue Feb 2, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 9ff0c1c Feb 2, 2026
30 checks passed
@champtar champtar deleted the publicca_mac_key branch February 2, 2026 19:11
NandiniAgrawal15 pushed a commit to NandiniAgrawal15/magic-modules that referenced this pull request Feb 5, 2026
wuchris-g pushed a commit to wuchris-g/magic-modules that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

b64url_mac_key empty when b64_mac_key is not b64url_mac_key returns empty value

3 participants