Add TLS transport option to pin the TLS version - #3
Merged
Merged
Conversation
Callers had no working way to pin the TLS version: a `versions`
entry in transport_opts is silently dropped, since connect/3 only
forwards `socket_opts`, `verify`, `cacerts` and the buffer sizes to
ssl:connect.
Add `{tls, "1.2"}` / `{tls, "1.3"}`, mapped to
`{versions, ['tlsv1.2']}` / `{versions, ['tlsv1.3']}` in both
connect/3 and upgrade/5. Any other value raises
`{invalid_tls_version, Value}` before connecting. Without the option,
the OTP default applies, as before.
When TLS 1.3 is pinned, drop the hardcoded `{reuse_sessions, true}`:
it is a TLS =< 1.2 option, and OTP rejects it alongside a
TLS-1.3-only version list with
`{options, incompatible, [reuse_sessions, {versions, ['tlsv1.3']}]}`.
Verified against a live server: "1.2" negotiates tlsv1.2, "1.3"
negotiates tlsv1.3, "1.1" is rejected.
codeadict
approved these changes
Sep 25, 2026
codeadict
left a comment
Owner
There was a problem hiding this comment.
Awesome, really exciting to see a PR on this. Wondering if you are using the library for something. Thanks
Contributor
Author
Oh yes. We use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Callers have no working way to pin the TLS version. A
versionsentry intransport_optsis silently dropped:gen_http_ssl:connect/3only forwardssocket_opts,verify,cacertsand the buffer sizes tossl:connect.Change
{tls, "1.2"}/{tls, "1.3"}transport option, mapped to{versions, ['tlsv1.2']}/{versions, ['tlsv1.3']}in bothconnect/3andupgrade/5.{invalid_tls_version, Value}before connecting.{reuse_sessions, true}is dropped. It is a TLS =< 1.2 option, and OTP rejects it alongside a TLS-1.3-only version list:{options, incompatible, [reuse_sessions, {versions, ['tlsv1.3']}]}Verification
Against a live server, reading
ssl:connection_information(Socket, [protocol]):{tls, "1.2"}tlsv1.2negotiated{tls, "1.3"}tlsv1.3negotiated{tls, "1.1"}{invalid_tls_version, "1.1"}