Skip to content

getinfo: repair CURLINFO_TLS_SESSION - #21290

Closed
bagder wants to merge 9 commits into
masterfrom
bagder/TLS-info
Closed

bagder wants to merge 9 commits into
masterfrom
bagder/TLS-info

Conversation

@bagder

@bagder bagder commented Apr 10, 2026

Copy link
Copy Markdown
Member

This should return a SSL_CTX pointer but it was accidentally broken.

Follow-up to 2db8ae4

Spotted by Codex Security

This should return a SSL_CTX pointer but it was accidentally broken.

Follow-up to 2db8ae4

Spotted by Codex Security
@bagder
bagder requested a review from icing April 10, 2026 13:56
@bagder
bagder requested a review from Copilot April 10, 2026 14:00
@bagder
bagder marked this pull request as ready for review April 10, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes curl_easy_getinfo() handling of CURLINFO_TLS_SESSION so it again returns the legacy TLS “session” internal pointer (e.g., SSL_CTX* for OpenSSL / WOLFSSL_CTX* for wolfSSL), which had regressed and started returning the same pointer as CURLINFO_TLS_SSL_PTR.

Changes:

  • Select the appropriate cfilter query (CF_QUERY_SSL_INFO vs CF_QUERY_SSL_CTX_INFO) depending on whether CURLINFO_TLS_SSL_PTR or CURLINFO_TLS_SESSION is requested.
  • Extend Curl_conn_get_ssl_info() to accept a query parameter and pass it through to the connection filter chain.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/getinfo.c Uses CF_QUERY_SSL_CTX_INFO for CURLINFO_TLS_SESSION to restore SSL_CTX/WOLFSSL_CTX semantics.
lib/cfilters.h Updates Curl_conn_get_ssl_info() declaration to accept a query selector.
lib/cfilters.c Updates Curl_conn_get_ssl_info() definition to forward the requested query type to cft->query().

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

Comment thread lib/cfilters.h Resolved
Comment thread lib/getinfo.c Resolved
@github-actions github-actions Bot added the tests label Apr 10, 2026
@bagder

bagder commented Apr 10, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode

augmentcode Bot commented Apr 10, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Repairs the legacy behavior of CURLINFO_TLS_SESSION so it again returns an SSL_CTX* (instead of the active SSL*) for OpenSSL-family backends, matching the documented contract.

Changes:

  • Extends Curl_conn_get_ssl_info() to accept a cfilter query selector and forwards it to the filter chain.
  • Updates getinfo_slist() to request CF_QUERY_SSL_CTX_INFO for CURLINFO_TLS_SESSION and CF_QUERY_SSL_INFO for CURLINFO_TLS_SSL_PTR.
  • Documents the new query parameter in lib/cfilters.h.
  • Adds regression test 1587 (data file + libtest) that exercises both info values on OpenSSL by calling SSL_CTX_* vs SSL_* APIs on the returned pointer.
  • Wires the new test into the tests Makefiles.

Technical Notes: Uses the existing cfilter query() mechanism (CF_QUERY_SSL_INFO/CF_QUERY_SSL_CTX_INFO) to select between per-connection TLS handle vs TLS context when the backend differentiates.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tests/libtest/lib1587.c Resolved
@bagder bagder closed this in 3e40ccb Apr 11, 2026
@bagder
bagder deleted the bagder/TLS-info branch April 11, 2026 14:56
dkarpov1970 pushed a commit to dkarpov1970/curl that referenced this pull request Apr 13, 2026
This should return a SSL_CTX pointer but it was accidentally broken.

Verify with test 1587

Follow-up to 2db8ae4

Spotted by Codex Security

Closes curl#21290
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
This should return a SSL_CTX pointer but it was accidentally broken.

Verify with test 1587

Follow-up to 2db8ae4

Spotted by Codex Security

Closes curl#21290
vszakats added a commit that referenced this pull request Jun 26, 2026
By exposing and reusing existing custom type via `vtls/openss.h`.

Also:
- GHA/curl-for-win: test in CI by enabling building tests.
  Cost is 45s per job, so limit it to the gcc job.

Seen with Windows x64 gcc (not tested in CI prior to this patch):
```
tests/libtest/lib1587.c:50:7: error: conversion from 'opt1587' {aka 'long long unsigned int'} to 'long int' may change value [-Werror=conversion]
   50 |       SSL_CTX_set_options(info->internals, opts);
      |       ^~~~~~~~~~~~~~~~~~~
tests/libtest/lib1587.c:59:7: error: conversion from 'opt1587' {aka 'long long unsigned int'} to 'long int' may change value [-Werror=conversion]
   59 |       SSL_set_options(info->internals, opts);
      |       ^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/28258372229/job/83727170184?pr=22195#step:3:4884

Ref: da2f05e #22198
Ref: 6163566 #22197
Follow-up to 3e40ccb #21290
Follow-up to 2db8ae4 #17809 #17801

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

Development

Successfully merging this pull request may close these issues.

2 participants