Skip to content

Conversation

Julia-Garland
Copy link
Contributor

@Julia-Garland Julia-Garland commented Oct 7, 2025

Summary

Follow up to #2118. Handles the SEC_I_RENEGOTIATE status received when TLS 1.3 is enabled with Windows Secure Channel.

Background

Secure Channel with TLS 1.3 may use the renegotiate status for internal use; instructions on how to handle this are given in Windows documentation:

“The DecryptMessage (Schannel) function will return SEC_I_RENEGOTIATE when Schannel is ready for your application to proceed. When you receive the SEC_I_RENEGOTIATE return code, your application must call AcceptSecurityContext (Schannel) (servers) or InitializeSecurityContext (Schannel) (clients), and pass the contents of SECBUFFER_EXTRA returned from DecryptMessage in the SECBUFFER_TOKEN. After this call returns a value, proceed as though your application were creating a new connection.”

Note the C driver does not handle SEC_I_RENEGOTIATE for TLS 1.1 and 1.2.

Used libcurl as an implementation reference.

Changes

Upon receipt of SEC_I_RENEGOTIATE, the driver will pass the contents of SECBUFFER_EXTRA to InitializeSecurityContext by calling mongoc_secure_channel_handshake_step_2.

In some cases, the data processed by a read may be completely consumed by the renegotiate handling. If this occurs and the read is non-blocking, _mongoc_stream_tls_secure_channel_readv will call read again to receive and decrypt the next message.

Added some extra fields to mongoc_stream_tls_secure_channel to keep the necessary information in scope.

@Julia-Garland Julia-Garland force-pushed the cdriver-6045-renegotiation branch from 6c60125 to d3bb538 Compare October 7, 2025 18:28
@Julia-Garland Julia-Garland marked this pull request as ready for review October 8, 2025 14:06
@Julia-Garland Julia-Garland requested a review from a team as a code owner October 8, 2025 14:06
'Windows (VS 2022)',
'windows-vsCurrent-large',
[
'.authentication-tests .winssl',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect the cause of the task failure in the new authentication-tests-winssl task is a missing dependent compile task. The test task tries to download the binaries built in the compile task. Try adding debug-compile-sspi-winssl.

@kevinAlbs kevinAlbs self-requested a review October 8, 2025 14:36
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.

2 participants