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

feat(transport): Integrate with enterprise certificate proxy #1570

Merged
merged 17 commits into from Jun 13, 2022

Conversation

andyrzhao
Copy link
Contributor

Enterprise Certificate Proxy (https://github.com/googleapis/enterprise-certificate-proxy) is the new preferred solution for certificate based access on the client-side, since it integrates directly with the native OS keystores and does not expose the underlying private key. This new solution leverages the ECP client to replace the existing SecureConnect cert provider code-path for devices with the new ECP configuration file and helper binaries installed. (The ECP configuration file and helper binaries will eventually be distributed and managed through gCloud SDK).

High-level change-list summary:

  • Refactored default_cert.go to split out SecureConnectSource into it's own file.
  • Added EnterpriseCertificateProxySource, a new client certificate source that uses the ECP client.
  • Updated tests and comments and added more test coverage.
  • Updated go.mod to include the new dependency.

Note that this change is safe and backwards compatible, since the ECP configuration file will not be present on devices without ECP binaries installed, in which case the DefaultSource will fall back to using SecureConnect. Furthermore, both the new ECP code-path and the old SecureConnect code-path are gated behind the env-var GOOGLE_API_USE_CLIENT_CERTIFICATE today.

@andyrzhao andyrzhao requested review from a team and yoshi-approver as code owners June 4, 2022 02:48
transport/cert/enterprise_cert.go Show resolved Hide resolved
transport/cert/enterprise_cert.go Show resolved Hide resolved
transport/cert/secureconnect_cert.go Outdated Show resolved Hide resolved
transport/cert/secureconnect_cert.go Outdated Show resolved Hide resolved
@shinfan
Copy link
Contributor

shinfan commented Jun 6, 2022

@codyoss Could you please help review this change? Thanks!

Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

Just a few comments, or else looks good

transport/cert/default_cert.go Outdated Show resolved Hide resolved
transport/cert/enterprise_cert.go Outdated Show resolved Hide resolved
transport/cert/internal/test_signer.go Outdated Show resolved Hide resolved
transport/cert/internal/test_signer.go Outdated Show resolved Hide resolved
transport/cert/secureconnect_cert.go Outdated Show resolved Hide resolved
transport/cert/secureconnect_cert.go Outdated Show resolved Hide resolved
transport/cert/secureconnect_cert.go Outdated Show resolved Hide resolved
transport/cert/testdata/context_aware_metadata.json Outdated Show resolved Hide resolved
Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

It looks like a .DS_Store file was accidentally commited.

@andyrzhao andyrzhao requested a review from codyoss June 8, 2022 17:13
Copy link
Member

@codyoss codyoss left a comment

Choose a reason for hiding this comment

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

Just a coupe more small things.

defaultCert.source, defaultCert.err = NewEnterpriseCertificateProxySource("")
if errors.Is(defaultCert.err, errSourceUnavailable) {
defaultCert.source, defaultCert.err = NewSecureConnectSource("")
if errors.Is(defaultCert.err, errSourceUnavailable) {
Copy link
Member

Choose a reason for hiding this comment

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

I don' think this case3 is needed. In the case that err is non-nil and a source can't be detected we should just return the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the reason why we return "nil, nil" when DefaultSource is unavailable is because the eventual caller of DefaultSource will take a different action when we don't have a certificate (i.e. it will not use mTLS path) - we don't want to error out in this scenario (in other words, nil Source is an acceptable return value). The other possibility to support this semantics is to export "errSourceUnavailable", so the caller can condition on that, but not sure if exporting custom errors is good practice, and it would also technically be non-backwards-compatible. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

You are right it would be a behavior change, but until this commit I don't think we documented that a nil error could be returned. It is definitely a grey area as far as breaking changes are concerned. But after thinking more I agree with you that although the current semantics are not ideal, I think it is best to keep them the same to avoid potential breakages.

transport/cert/enterprise_cert.go Outdated Show resolved Hide resolved
transport/cert/secureconnect_cert_test.go Outdated Show resolved Hide resolved
@codyoss codyoss enabled auto-merge (squash) June 13, 2022 18:43
@codyoss codyoss merged commit 1d5389b into googleapis:main Jun 13, 2022
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.

None yet

3 participants