Skip to content

fix: compose user SSL_create_ctx_callback with internal MODE_AUTO_RETRY#21

Draft
Koan-Bot wants to merge 1 commit into
Perl-Toolchain-Gang:masterfrom
Koan-Bot:koan.atoomic/fix-issue-19
Draft

fix: compose user SSL_create_ctx_callback with internal MODE_AUTO_RETRY#21
Koan-Bot wants to merge 1 commit into
Perl-Toolchain-Gang:masterfrom
Koan-Bot:koan.atoomic/fix-issue-19

Conversation

@Koan-Bot
Copy link
Copy Markdown

@Koan-Bot Koan-Bot commented Mar 19, 2026

Summary

When a user provides SSL_create_ctx_callback in SSL_options, HTTP::Tiny was silently overwriting it with its own internal callback that sets Net::SSLeay::MODE_AUTO_RETRY. This prevented advanced TLS use cases such as restricting signature algorithms to connect to dual-certificate servers (post-quantum + RSA).

The fix captures the user-provided callback before calling IO::Socket::SSL::start_SSL and composes it with the internal callback: MODE_AUTO_RETRY is always set first, then the user's callback is invoked. If no user callback is provided, behaviour is unchanged.

Fixes #19

Changes

  • lib/HTTP/Tiny.pm: In HTTP::Tiny::Handle::start_ssl, extract any user-provided SSL_create_ctx_callback from _ssl_args and compose it with the internal MODE_AUTO_RETRY callback instead of replacing it.
  • t/185_ssl_ctx_callback.t: New test file verifying that _ssl_args preserves the user callback, that start_ssl composes both callbacks correctly, and that behaviour without a user callback is unchanged.

Test plan

  • New test t/185_ssl_ctx_callback.t (7 assertions): mocks IO::Socket::SSL::start_SSL and Net::SSLeay::CTX_set_mode to verify both the internal MODE_AUTO_RETRY and the user callback are called from the composed callback.
  • Full test suite (prove -Ilib t/*.t): all 32 test files pass, 465 assertions.

Generated by Kōan /fix


Quality Report

Changes: 2 files changed, 113 insertions(+)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

…RY callback

When a user provides SSL_create_ctx_callback in SSL_options, HTTP::Tiny
was silently overwriting it with its own internal callback that sets
Net::SSLeay::MODE_AUTO_RETRY. This prevented use cases such as
restricting signature algorithms for dual-certificate servers.

The fix captures the user-provided callback from the ssl_args hash (which
already includes user SSL_options) and composes it with the internal
callback: MODE_AUTO_RETRY is set first, then the user's callback is called.
If no user callback is provided, behaviour is unchanged.

Fixes Perl-Toolchain-Gang#19

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

SSL_create_ctx_callback parameter in SSL_options

1 participant