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

L46: C-core: New TLS Credentials API #422

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

gtcooke94
Copy link

@gtcooke94 gtcooke94 commented Mar 22, 2024

This PR is subsuming the previous PR of the same title (#205), and attempting to bring the content to the current state with the goal of formally merging this and moving these API from experimental to stable.

This is still under active work and is not ready for final review.

@gtcooke94 gtcooke94 marked this pull request as draft March 22, 2024 17:42
Copy link
Author

@gtcooke94 gtcooke94 left a comment

Choose a reason for hiding this comment

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

Did a rework of the cert provider section, still need to address the verification side

L46-core-tls-credential-API.md Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Show resolved Hide resolved
L46-core-tls-credential-API.md Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
// (in the one-side TLS scenario, the server is not required to provide root
// certs). We don't support default root certs on server side.
void watch_root_certs();
// Sets the name of root certificates being watched, if |watch_root_certs| is

Choose a reason for hiding this comment

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

Pinging this so we don't lose it.

L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
~TlsCustomVerificationCheckRequest() {}

absl::string_view target_name() const;
absl::string_view peer_cert() const;

Choose a reason for hiding this comment

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

I think that comment is another signal that this API is not useful for anyone since they cannot really predict what the return value should be. I think we should probably deprecate + delete this API and replace it with APIs that return predictable and explicit values.

L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
L46-core-tls-credential-API.md Outdated Show resolved Hide resolved
// Sets the certificate verifier. The certificate verifier performs checks on
// the peer certificate chain after the chain has been (cryptographically)
// verified to chain up to a trusted root.
// If unset, this will default to the `HostNameCertificateVerifier` detailed

Choose a reason for hiding this comment

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

We should note that, if you call set_certificate_verifier(nullptr), this will overwrite the host name verifier and lead you to not doing any checks (aside from the cryptographic ones).

Copy link
Author

Choose a reason for hiding this comment

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

Added

// Sets the certificate verifier. The certificate verifier performs checks on
// the peer certificate chain after the chain has been (cryptographically)
// verified to chain up to a trusted root.
// If unset, this will default to the `HostNameCertificateVerifier` detailed

Choose a reason for hiding this comment

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

Should it only do this default on the client-side?

Copy link
Author

Choose a reason for hiding this comment

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

That's a good question - I think it depends on other defaults, and if we are doing MTLS vs. TLS? I'll double check, but I don't believe this is called unless it is configured to do MTLS.

Note that there is a naming mismatch here - there exist credentials beyond
certificates that this _could_ theoretically support. This provider is
responsible for sourcing key material and supplying it to the internal stack via
the `CertificateProvider`'s `SetKeyMaterials` API. Two reference

Choose a reason for hiding this comment

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

This sentence needs to be updated as the SetKeyMaterials API no longer exists.

Copy link
Author

Choose a reason for hiding this comment

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

I believe I already fixed this in the most recent commit, PTAL

// Does important internal setup steps.
void Start();

// The case of a SPIFFE trust bundle still falls into RootCertificates, it's

Choose a reason for hiding this comment

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

This comment is coming from the review but, as written, it's a bit of a non sequitur. Can we add comments for each line in the enum, and this can be part of the RootCertificates comment?

Copy link
Author

Choose a reason for hiding this comment

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

Changed, PTAL

public:
virtual ~CertificateProviderInterface() = default;

// Must be called after the constructor.

Choose a reason for hiding this comment

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

The user does not call the constructor, so should we say e.g. "// Starts the provider. Must be called before the provider is used for any TLS handshakes."?

Copy link
Author

Choose a reason for hiding this comment

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

Changed

// identity certificates(single side TLS).
class TlsChannelCredentialsOptions final : public TlsCredentialsOptions {
public:
// Sets the decision of whether to do a crypto check on the server certs.

Choose a reason for hiding this comment

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

Despite the other comment, I think we need to clean up this comment so that it is more precise. :)

~TlsCustomVerificationCheckRequest() {}

absl::string_view target_name() const;
absl::string_view peer_cert() const;

Choose a reason for hiding this comment

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

How do we get a verified chain on resumed handshakes?

// If error status, failed synchronously.
// If OK status and true, succeeded synchronously.
// If OK status and false, verification is still in progress asynchronously.
virtual absl::StatusOr<bool> Verify(VerifiedPeerCertificateChainInfo* request,

Choose a reason for hiding this comment

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

micro-nit: I don't think the variable name should still be "request".

Copy link
Author

Choose a reason for hiding this comment

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

Changed to verified_chain_info

// verification request is pending.
//
// request: the verification information associated with this request
virtual void Cancel(VerifiedPeerCertificateChainInfo* request) = 0;

Choose a reason for hiding this comment

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

micro-nit: I don't think the variable name should still be "request".

Copy link
Author

Choose a reason for hiding this comment

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

Changed to verified_chain_info

*/
// This represents a potential decoupling of roots and identity chains, with
// further extension points for something like SPIFFE bundles
class CertificateProviderInterface {

Choose a reason for hiding this comment

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

Apologies if I'm a broken record with the "watch_root_certs" and "set_root_cert_name" APIs: can we move this functionality to the cert provider rather than having it on the options?

Copy link
Author

Choose a reason for hiding this comment

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

I don't believe so - I believe the intention is that a provider could be serving many different sets of creds, thus they need to be separated by user-defined names.
Then the specific TlsCredentialsOptions struct used to create a specific TlsCredentials needs to know which creds from the provider they need, so the name has to be set there.

@gtcooke94 gtcooke94 marked this pull request as ready for review June 11, 2024 17:13
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

4 participants