Optional tls_params in certificate to override TLS params in context#45680
Optional tls_params in certificate to override TLS params in context#45680rudrakhp wants to merge 10 commits into
Conversation
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
61f0b97 to
8d7cf14
Compare
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
8d7cf14 to
37ec457
Compare
|
I will leave this to the expert of TLS. |
ggreenway
left a comment
There was a problem hiding this comment.
I don't think this works.
// SSL_set_SSL_CTX changes |ssl|'s |SSL_CTX|. |ssl| will use the
// certificate-related settings from |ctx|, and |SSL_get_SSL_CTX| will report
// |ctx|. This function may be used during the callbacks registered by
// |SSL_CTX_set_select_certificate_cb|,
// |SSL_CTX_set_tlsext_servername_callback|, and |SSL_CTX_set_cert_cb| or when
// the handshake is paused from them. It is typically used to switch
// certificates based on SNI.
//
// Note the session cache and related settings will continue to use the initial
// |SSL_CTX|. Callers should use |SSL_CTX_set_session_id_context| to partition
// the session cache between different domains.
//
// TODO(davidben): Should other settings change after this call?
OPENSSL_EXPORT SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);
This only affects the certificate-related settings, and most of the newly-added settings wouldn't be applied.
/wait
cad1603 to
5c44f82
Compare
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
5c44f82 to
0be0fc5
Compare
|
@ggreenway Thanks for the review! I updated the implementation to apply the selected certificate’s TLS params directly on |
|
Don't force-push to the PR branch; it makes it difficult to review. |
| // for that certificate during the TLS handshake; unset fields continue to use the context-level | ||
| // values. This allows different cipher suites, ECDH curves, protocol versions, signature | ||
| // algorithms, or compliance policies per certificate. | ||
| // Setting this on a client certificate has no effect. |
There was a problem hiding this comment.
Is there somewhere else this can be configured, so we don't have a setting that only works some of the time?
@wbpcode can you comment as the api-reviewer?
There was a problem hiding this comment.
Some params like the ocsp_staple are configured under TlsCertificate but is supported in downstream context (server cert) only. Per cert TLS params made sense to exist under each corresponding cert.
We could rename it to downstream_tls_params or server_tls_params to be more explicit about its usage?
There was a problem hiding this comment.
I don't know a better position for that. And if we can support this at upstream in theory, then it's fine to place it here and document it clear that this only make sense for now for downstream TLS.
And in the future, if we see similar requirement at upstream, we can implement it at upstream TLS also.
Ack. I added a new commit after your last review to make it easier to see the changes since then. I only force pushed on the new commit while iterating on a few test failures. Will avoid doing that as well if you would prefer no force pushes at all :) |
wbpcode
left a comment
There was a problem hiding this comment.
/lgtm api
My two cents to the API. :)
|
coverage finding looks relevant. |
There was a problem hiding this comment.
There's copy/pasted code all over this PR. Please refactor to avoid that.
The tests are currently not covering ecdh_curves or max_protocol_version, and they don't cover TLSv1.3 handshakes. Please add coverage for all the settings, using both TLSv1.2 and TLSv1.3.
/wait
| if (p.compliance_policies_size() > 1) { | ||
| creation_status = absl::InvalidArgumentError( | ||
| "Only one compliance policy may be specified per certificate tls_params"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Use compliancePolicyFromProto() here and line 149
There was a problem hiding this comment.
Moving compliancePolicyFromProto() to utils to avoid cyclic dependencies
| std::vector<absl::string_view> ciphers = | ||
| StringUtil::splitToken(tls_params_->cipher_suites, ":+![|]", false); |
There was a problem hiding this comment.
You've copied a lot of code from elsewhere. Refactor so there's not duplicated config handling code, so that it can't drift over time.
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
| // QUIC selects certs via ProofSource::GetProof(), not cert_cb, so tls_params_ never applies | ||
| // there. |
There was a problem hiding this comment.
I have not implemented this for QUIC/HTTP3 in this PR (also documented it in API docs and changelogs). We can implement this in a follow up if required?
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Commit Message: optional tls params in certificate
Additional Description: Add optional
tls_paramsin TLS certificate SDS that overrides context level TLS params for the certificate if provided.Risk Level: Low (new API)
Testing: Unit tests
Docs Changes: N/A
Release Notes: Yes
Platform Specific Features: N/A
Related #44021