Skip to content

tls: remove checks for DEFAULT#20453

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/tls-default-adjust
Closed

tls: remove checks for DEFAULT#20453
bagder wants to merge 1 commit intomasterfrom
bagder/tls-default-adjust

Conversation

@bagder
Copy link
Member

@bagder bagder commented Jan 27, 2026

Since 9d8998c, the setopt code changes input DEFAULT to an actual more specific TLS version (1.2) for the backends to use and check for.

This means that the default value (0L) cannot and should not actually be used when the TLS backends run. This change adds asserts to verify that and removes code that accepts the DEFAULT value as a valid version within the TLS version functions' logic.

Applications can still set a specific lower version if they want (1, 1.0 or 1.1).

Since 9d8998c, the setopt code changes input DEFAULT to an
actual more specific TLS version (1.2) for the backends to use and check
for.

This means that the default value (0L) cannot and should not actually be
used when the TLS backends run. This change adds asserts to verify that
and removes code that accepts the DEFAULT value as a valid version with
the TLS version functions' logic.

Applications can still set a specific lower version if they want (1, 1.0
or 1.1).
@bagder bagder added the TLS label Jan 27, 2026
@bagder bagder requested a review from Copilot January 27, 2026 22:34
@bagder bagder marked this pull request as ready for review January 27, 2026 22:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request removes checks for CURL_SSLVERSION_DEFAULT from TLS backend implementations, following a change where the setopt code now converts DEFAULT (0) to TLSv1.2 before the backends process it. The PR adds defensive assertions to verify that DEFAULT is never passed to backends and removes now-unreachable code branches.

Changes:

  • Added DEBUGASSERT statements in all TLS backends to verify that CURL_SSLVERSION_DEFAULT is not passed to backend functions
  • Removed case CURL_SSLVERSION_DEFAULT: statements from switch blocks in TLS backend version handling code
  • Simplified condition in gtls.c from explicit check for DEFAULT/TLSv1 to a less-than-or-equal comparison

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/vtls/wolfssl.c Added DEBUGASSERT and removed DEFAULT case from ssl_version switch
lib/vtls/schannel.c Added DEBUGASSERT and removed DEFAULT case from version switch
lib/vtls/rustls.c Added DEBUGASSERT and removed DEFAULT case from init_config_builder switch
lib/vtls/openssl.c Added DEBUGASSERT in two functions and removed DEFAULT cases from two switch statements
lib/vtls/mbedtls.c Added DEBUGASSERT and removed DEFAULT case from mbed_set_ssl_version_min_max switch
lib/vtls/gtls.c Added DEBUGASSERT and changed condition from explicit DEFAULT/TLSv1 check to <= TLSv1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder closed this in 1b50dcc Jan 27, 2026
@bagder bagder deleted the bagder/tls-default-adjust branch January 27, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants