Skip to content

Comments

Modify is_tls13_capable() to take account of the servername cb#13304

Closed
mattcaswell wants to merge 2 commits intoopenssl:masterfrom
mattcaswell:servername-tls13
Closed

Modify is_tls13_capable() to take account of the servername cb#13304
mattcaswell wants to merge 2 commits intoopenssl:masterfrom
mattcaswell:servername-tls13

Conversation

@mattcaswell
Copy link
Member

A servername cb may change the available certificates, so if we have one
set then we cannot rely on the configured certificates to determine if we
are capable of negotiating TLSv1.3 or not.

Fixes #13291

A servername cb may change the available certificates, so if we have one
set then we cannot rely on the configured certificates to determine if we
are capable of negotiating TLSv1.3 or not.

Fixes openssl#13291
If an SNI callback has been set then we may have no certificuates suitable
for TLSv1.3 use configured for the current SSL_CTX. This should not prevent
us from negotiating TLSv1.3, since we may change the SSL_CTX by the time we
need a suitable certificate.
@mattcaswell
Copy link
Member Author

1.1.1 backport is in #13305.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

Approved provided the comment nit is fixed.

* certificate type, or has PSK or a certificate callback configured. Otherwise
* returns 0.
* certificate type, or has PSK or a certificate callback configured, or has
* a servername callback configure. Otherwise returns 0.
Copy link
Member

Choose a reason for hiding this comment

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

s/configure/configured/

@t8m t8m added the approval: done This pull request has the required number of approvals label Nov 3, 2020
@kaduk
Copy link
Contributor

kaduk commented Nov 3, 2020

I would prefer if this change was not necessary, given that it is adding yet more complexity to the already intertwined dependencies of handshake processing. That said, I cannot fully object, since we already have PSK callback checks, but it seems like it is going in the wrong direction. The current behavior of the servername_cb is constrained by many consumers and use cases that evolved organically to depend on particular implementation choices, and are sensitive to any reordering of handshake processing. I believe that the client_hello_cb is the appropriate place for application code that needs to affect TLS version negotiation to reside, since that callback has clear and well-defined semantics with respect to the rest of handshake processing.

@mattcaswell
Copy link
Member Author

I believe that the client_hello_cb is the appropriate place for application code that needs to affect TLS version negotiation to reside, since that callback has clear and well-defined semantics with respect to the rest of handshake processing.

Please take a look at the comments in #13291. The nginx developers believe that the client_hello_cb does not meet their needs (apparently they tried it and abandoned it).

Whilst we might prefer users to use the client_hello_cb we have not chosen to deprecate the servername_cb and this PR addresses an issue that looks like a clear bug which should be fixed IMO.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@kroeckx kroeckx added hold: discussion The community needs to establish a consensus how to move forward with the issue or PR and removed approval: done This pull request has the required number of approvals labels Nov 4, 2020
@kroeckx
Copy link
Member

kroeckx commented Nov 4, 2020

I've put a hold flag on it, until there is sufficient time to see that this is the way we want to do it.

@kaduk
Copy link
Contributor

kaduk commented Nov 5, 2020

I believe that the client_hello_cb is the appropriate place for application code that needs to affect TLS version negotiation to reside, since that callback has clear and well-defined semantics with respect to the rest of handshake processing.

Please take a look at the comments in #13291. The nginx developers believe that the client_hello_cb does not meet their needs (apparently they tried it and abandoned it).

Yes, I already commented there and it looks like there was a followup to help clarify the concerns and whether new APIs can address some or all of them.

Whilst we might prefer users to use the client_hello_cb we have not chosen to deprecate the servername_cb and this PR addresses an issue that looks like a clear bug which should be fixed IMO.

Well, it addresses an issue and introduces another, so there's a tradeoff. We in general try to provide protection against failed negotiations, in this case by not considering TLS versions that are incompatible with the configured server certificate. This is problematic when the server certificate is going to change and the new certificate would be compatible with other TLS versions, which motivates relaxing the check, but if we relax the check then someone who is going to change the certificate to one that is not compatible with TLS 1.3 will experience a handshake failure, as we negotiate 1.3 and then discover that the certificate is incompatible. So it's a tradeoff.

I note that I chose my words carefully in "prefer if this change was not necessary" (implying that it may well be necessary), since our precedent for similar cases is to relax the check and leave the application code with the responsibility for performing the analogous check.

@mattcaswell
Copy link
Member Author

I note that I chose my words carefully in "prefer if this change was not necessary" (implying that it may well be necessary), since our precedent for similar cases is to relax the check and leave the application code with the responsibility for performing the analogous check.

I consider it necessary.

@t8m
Copy link
Member

t8m commented Nov 6, 2020

Would alternative fix that does not return 0 from is_tls13_capable() in case no certificate is set at all would be acceptable? The reason is that running anonymous server is highly improbable anyway. Or return 0 or 1 in this case based on whether the servername_cb is set or not.

@kroeckx kroeckx removed the hold: discussion The community needs to establish a consensus how to move forward with the issue or PR label Dec 2, 2020
@kroeckx
Copy link
Member

kroeckx commented Dec 2, 2020

So what are we going to do with this PR?

@mattcaswell
Copy link
Member Author

So what are we going to do with this PR?

It was waiting for OTC to decide what we were going to do - so not sure why you removed the OTC hold.

@kroeckx
Copy link
Member

kroeckx commented Dec 2, 2020 via email

@mattcaswell mattcaswell added the approval: done This pull request has the required number of approvals label Dec 2, 2020
@mattcaswell
Copy link
Member Author

I added the OTC hold label because it was approved, but I think it
needed to have some time for to discuss it. If you think it needs
an actual OTC decission, can someone at least start a discussion
about it?

Well, I'm happy with it as it is. I thought others wanted that discussion. If not then I'm happy to proceed with it as is.
I'll leave it another day or so and see if anyone else decides to apply the OTC hold label. If not, I'll merge.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

openssl-machine pushed a commit that referenced this pull request Dec 9, 2020
A servername cb may change the available certificates, so if we have one
set then we cannot rely on the configured certificates to determine if we
are capable of negotiating TLSv1.3 or not.

Fixes #13291

Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #13304)
openssl-machine pushed a commit that referenced this pull request Dec 9, 2020
If an SNI callback has been set then we may have no certificuates suitable
for TLSv1.3 use configured for the current SSL_CTX. This should not prevent
us from negotiating TLSv1.3, since we may change the SSL_CTX by the time we
need a suitable certificate.

Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #13304)
@mattcaswell
Copy link
Member Author

Well, I'm happy with it as it is. I thought others wanted that discussion. If not then I'm happy to proceed with it as is.
I'll leave it another day or so and see if anyone else decides to apply the OTC hold label. If not, I'll merge.

No one objected or added the OTC hold label, so I have pushed to master. The 1.1.1 version still seems to have the hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nginx 1.19.4 feature "ssl_reject_handshake" does not work as intended with openssl

5 participants