Skip to content

Conversation

@rzikm
Copy link
Member

@rzikm rzikm commented Mar 6, 2024

Fixes #99289.

When server issues HelloRetryRequest and client sends a second ClientHello message, we need to do a second round of ALPN selection, so we need to keep it alpn list handle still set in the Ssl ex data slot.

The ALPN list handle is going to be alive until the end of the SSL object lifetime, so there is no risk of dangling pointer as the comment claims.

if (AlpnHandle.IsAllocated)
{
Interop.Ssl.SslSetData(handle, IntPtr.Zero);
AlpnHandle.Free();
}

@ghost ghost assigned rzikm Mar 6, 2024
@ghost
Copy link

ghost commented Mar 6, 2024

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #99289.

When server issues HelloRetryRequest and client sends a second ClientHello message, we need to do a second round of ALPN selection, so we need to keep it around and not set the ptr to null.

The ALPN list handle is going to be alive until the end of the SSL object lifetime

if (AlpnHandle.IsAllocated)
{
Interop.Ssl.SslSetData(handle, IntPtr.Zero);
AlpnHandle.Free();
}

Author: rzikm
Assignees: -
Labels:

area-System.Net.Security

Milestone: -

@rzikm rzikm marked this pull request as ready for review March 6, 2024 14:32
@rzikm rzikm requested a review from wfurt March 6, 2024 14:32
@rzikm
Copy link
Member Author

rzikm commented Mar 6, 2024

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

Can we craft test using NegotiateClientCertificateAsync? It does not need to send cert IMHO just a way how to trigger renegotiation. Perhaps do Theory for 1.2 and 1.3 separately....?

@rzikm
Copy link
Member Author

rzikm commented Mar 6, 2024

Can we craft test using NegotiateClientCertificateAsync? It does not need to send cert IMHO just a way how to trigger renegotiation. Perhaps do Theory for 1.2 and 1.3 separately....?

I don't think renegotiation triggers this, its triggered by server sending HelloRetryRequest in response to ClientHello, and I don't think we have public API which can trigger this (I had to manipulate the openssl.cnf to reproduce the issue).

@wfurt
Copy link
Member

wfurt commented Mar 6, 2024

Can we craft test using NegotiateClientCertificateAsync? It does not need to send cert IMHO just a way how to trigger renegotiation. Perhaps do Theory for 1.2 and 1.3 separately....?

I don't think renegotiation triggers this, its triggered by server sending HelloRetryRequest, and I don't think we have public API which can trigger this (I had to manipulate the openssl.cnf to reproduce the issue).

Wouldn't the handshake logic be triggered again ... including the callback? I think it does it for certificate validation as far as I remember.

@rzikm
Copy link
Member Author

rzikm commented Mar 7, 2024

Classical renegotiation after the first handshake was completed does not trigger the ALPN selection callback (Otherwise, we would've noticed already because we test this code path for late client cert negotiation).

I have found some discussion at openssl/openssl#2767 and apparently OpenSSL ignores ALPN extension once the application protocol has been established by ServerHello.

@rzikm
Copy link
Member Author

rzikm commented Mar 7, 2024

Test failures are unrelated.

@rzikm
Copy link
Member Author

rzikm commented Mar 7, 2024

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rzikm rzikm requested a review from wfurt March 12, 2024 10:18
Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM

@rzikm
Copy link
Member Author

rzikm commented Mar 13, 2024

CI failures are unrelated

@rzikm rzikm merged commit e568fff into dotnet:main Mar 13, 2024
@rzikm
Copy link
Member Author

rzikm commented Mar 13, 2024

/backport to release/8.0-staging

@github-actions
Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/8262729469

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
@karelz karelz added this to the 9.0.0 milestone May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TLS 1.3 negotiation fails with FIPS-enabled Ubuntu 22.04 server and Chromium based browsers

3 participants