Skip to content

openssl: fix OpenSSL v4.1 no-deprecated build - #23215

Closed
MarcelRaad wants to merge 1 commit into
curl:masterfrom
MarcelRaad:openssl_v4.1
Closed

MarcelRaad wants to merge 1 commit into
curl:masterfrom
MarcelRaad:openssl_v4.1

Conversation

@MarcelRaad

Copy link
Copy Markdown
Member

ASN1_STRING_length has been replaced by ASN1_STRING_get_length in the OpenSSL v4.1 API, which now returns size_t instead of int.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:45
@github-actions github-actions Bot added the TLS label Oct 1, 2026

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.

Copilot review overview

🟡 Changes recommended

The compatibility shim converts negative lengths to SIZE_MAX, risking out-of-bounds reads.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Updates OpenSSL ASN.1 length handling for OpenSSL 4.1 compatibility.

Changes:

  • Adds a pre-4.1 compatibility shim.
  • Migrates certificate parsing to size_t lengths.
File Description
lib/​vtls/​openssl.c Updates ASN.1 length access and related types.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/vtls/openssl.c Resolved
`ASN1_STRING_length` has been replaced by `ASN1_STRING_get_length` in
the OpenSSL v4.1 API, which now returns `size_t` instead of `int`.

Closes curl#23215

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.

Copilot review overview

🟢 Approval recommended

The compatibility migration is complete and preserves safe behavior across supported OpenSSL versions.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@jay jay closed this in 978cce1 Oct 2, 2026
@jay

jay commented Oct 2, 2026

Copy link
Copy Markdown
Member

Thanks

@MarcelRaad
MarcelRaad deleted the openssl_v4.1 branch October 2, 2026 08:04
GauChoob added a commit to elmadev/elma-classic that referenced this pull request Oct 18, 2026
The macos-26 runner has been updated from openssl 3.6.4 to 4.0.3

This new version of openssl is only supported as of curl-8.20.0
curl/curl#21119

For future reference, openssl 4.1 is supported by curl-8.23.0
curl/curl#23215

The latest libcurl port to meson is curl-8.12.1
Disable openssl for macos-26, falling back to use secure transport
GauChoob added a commit to elmadev/elma-classic that referenced this pull request Oct 18, 2026
The macos-26 runner has been updated from openssl 3.6.4 to 4.0.3

Openssl 4.0 is only supported as of curl-8.20.0 curl/curl#21119
Openssl 4.1 is only supported as of curl-8.23.0 curl/curl#23215
jgouly pushed a commit to elmadev/elma-classic that referenced this pull request Oct 18, 2026
The macos-26 runner has been updated from OpenSSL 3.6.4 to 4.0.3.

OpenSSL 4.0 is only supported as of curl-8.20.0 curl/curl#21119
OpenSSL 4.1 is only supported as of curl-8.23.0 curl/curl#23215
jgouly pushed a commit to elmadev/elma-classic that referenced this pull request Oct 18, 2026
The macos-26 runner has been updated from OpenSSL 3.6.4 to 4.0.3.

OpenSSL 4.0 is only supported as of curl-8.20.0 curl/curl#21119
OpenSSL 4.1 is only supported as of curl-8.23.0 curl/curl#23215
vszakats added a commit to vszakats/curl that referenced this pull request Oct 20, 2026
vszakats added a commit that referenced this pull request Oct 20, 2026
To avoid name clash when building against OpenSSL forks implementing
this API.

Fixing, when building against BoringSSL 0.20261020.0:
```
lib/vtls/openssl.c:173:15: error: static declaration of 'ASN1_STRING_get_length' follows non-static declaration
  173 | static size_t ASN1_STRING_get_length(const ASN1_STRING *str)
      |               ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/runner/pkg/boringssl/include/openssl/x509.h:23,
                 from /home/runner/pkg/boringssl/include/openssl/pem.h:25,
                 from /home/runner/pkg/boringssl/include/openssl/ssl.h:24,
                 from /home/runner/work/curl/curl/lib/vtls/openssl.h:69,
                 from /home/runner/work/curl/curl/lib/vtls/openssl.c:37:

/home/runner/pkg/boringssl/include/openssl/asn1.h:525:23: note: previous declaration of 'ASN1_STRING_get_length'
  with type 'size_t(const ASN1_STRING *)' {aka 'long unsigned int(const struct asn1_string_st *)'}

  525 | OPENSSL_EXPORT size_t ASN1_STRING_get_length(const ASN1_STRING *str);
      |                       ^~~~~~~~~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/39485527308/job/118844815062?pr=23519#step:38:42

Ref: #23519
Follow-up to 978cce1 #23215

Closes #23520
erikolofsson pushed a commit to Malterlib/curl that referenced this pull request Nov 17, 2026
To avoid name clash when building against OpenSSL forks implementing
this API.

Fixing, when building against BoringSSL 0.20261020.0:
```
lib/vtls/openssl.c:173:15: error: static declaration of 'ASN1_STRING_get_length' follows non-static declaration
  173 | static size_t ASN1_STRING_get_length(const ASN1_STRING *str)
      |               ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/runner/pkg/boringssl/include/openssl/x509.h:23,
                 from /home/runner/pkg/boringssl/include/openssl/pem.h:25,
                 from /home/runner/pkg/boringssl/include/openssl/ssl.h:24,
                 from /home/runner/work/curl/curl/lib/vtls/openssl.h:69,
                 from /home/runner/work/curl/curl/lib/vtls/openssl.c:37:

/home/runner/pkg/boringssl/include/openssl/asn1.h:525:23: note: previous declaration of 'ASN1_STRING_get_length'
  with type 'size_t(const ASN1_STRING *)' {aka 'long unsigned int(const struct asn1_string_st *)'}

  525 | OPENSSL_EXPORT size_t ASN1_STRING_get_length(const ASN1_STRING *str);
      |                       ^~~~~~~~~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/39485527308/job/118844815062?pr=23519#step:38:42

Ref: curl#23519
Follow-up to 978cce1 curl#23215

Closes curl#23520

(cherry picked from commit dfab21a)
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.

4 participants