Skip to content

(gcp_authn) add crypto utility for certificate fingerprinting#44956

Merged
tyxia merged 11 commits into
envoyproxy:mainfrom
antoniovleonti:gcp-authn-crypto-lib
May 20, 2026
Merged

(gcp_authn) add crypto utility for certificate fingerprinting#44956
tyxia merged 11 commits into
envoyproxy:mainfrom
antoniovleonti:gcp-authn-crypto-lib

Conversation

@antoniovleonti
Copy link
Copy Markdown
Contributor

Commit Message: (gcp_authn) add crypto utility for certificate fingerprinting
Additional Description:

This PR introduces the crypto_utils.h library, which provides the functionality to extract and validate certificate fingerprints from a secret provider. This will later be used to generate bound tokens in this filter.

See also: #44929

Risk Level: none (not used yet)
Testing: new unit tests added
Docs Changes: none
Release Notes: none

Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
@zuercher
Copy link
Copy Markdown
Member

zuercher commented May 8, 2026

Build failing because it doesn't meet the coverage requirements. I'll let the code owners here decide if we should adjust the requirement.

@tyxia
Copy link
Copy Markdown
Member

tyxia commented May 9, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a crypto_utils library for the GCP Authn filter to extract and validate certificate fingerprints. Review feedback highlights a logic issue where the current double-encoding method incorrectly encodes the '/' character; the reviewer suggests using absl::StrReplaceAll and updating the corresponding BUILD file and includes. Additionally, it is recommended to change the certificate chain logging level from info to debug to avoid excessive verbosity in production.

Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
Comment thread source/extensions/filters/http/gcp_authn/BUILD
Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
@antoniovleonti
Copy link
Copy Markdown
Contributor Author

/assign @botengyao

botengyao
botengyao previously approved these changes May 18, 2026
Copy link
Copy Markdown
Member

@botengyao botengyao left a comment

Choose a reason for hiding this comment

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

lgtm for the utility, thanks!

pass to @tyxia

Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. First pass

Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc
Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
Comment thread source/extensions/filters/http/gcp_authn/crypto_utils.cc Outdated
}

bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(file_content.data(), file_content.size()));
bssl::UniquePtr<X509> cert(PEM_read_bio_X509(bio.get(), nullptr, nullptr, nullptr));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PEM_read_bio_X509 reads only the first certificate from the PEM. If certificate_chain contains a full chain (leaf + intermediates + roots), it is not guaranteed that first cert is the leaf cert.

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.

You are technically correct. However, I think it's standard practice to put the leaf cert first in a PEM file. In TlsContext::loadCertificateChain, it is also assumed the leaf cert is the first cert.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you add a comment to document this?

@tyxia
Copy link
Copy Markdown
Member

tyxia commented May 19, 2026

/wait

Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Another high level comment: Does this function need to sit inside of gcp_authn? Could be be a generally useful library in common place like common/tls/utility.cc etc?

Signed-off-by: antoniovleonti <leonti@google.com>
@antoniovleonti
Copy link
Copy Markdown
Contributor Author

Another high level comment: Does this function need to sit inside of gcp_authn? Could be be a generally useful library in common place like common/tls/utility.cc etc?

I considered this, but decided against it due to YAGNI & our quickly approaching deadline to have this code-complete.

Signed-off-by: antoniovleonti <leonti@google.com>
Signed-off-by: antoniovleonti <leonti@google.com>
@antoniovleonti
Copy link
Copy Markdown
Contributor Author

/retest

Signed-off-by: antoniovleonti <leonti@google.com>
@tyxia
Copy link
Copy Markdown
Member

tyxia commented May 20, 2026

Another high level comment: Does this function need to sit inside of gcp_authn? Could be be a generally useful library in common place like common/tls/utility.cc etc?

I considered this, but decided against it due to YAGNI & our quickly approaching deadline to have this code-complete.

It is fine that we put it in gcp_authn due to dealine. My questions above is about whether this code will be YAGNI or not.

Let's proceed as it is for now and think about moving the code later

Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks,

Please address the comment around documentation in a follow-up pr

@tyxia tyxia merged commit f87cfd3 into envoyproxy:main May 20, 2026
29 checks passed
@antoniovleonti antoniovleonti deleted the gcp-authn-crypto-lib branch May 20, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants