Skip to content

Fix build with OpenSSL 4.x: replace direct ASN1_STRING member access#3956

Open
lemenkov wants to merge 1 commit into
OpenSIPS:masterfrom
lemenkov:openssl_opaque_types
Open

Fix build with OpenSSL 4.x: replace direct ASN1_STRING member access#3956
lemenkov wants to merge 1 commit into
OpenSIPS:masterfrom
lemenkov:openssl_opaque_types

Conversation

@lemenkov

Copy link
Copy Markdown
Contributor

Summary

Fix build failure with OpenSSL 4.0.x where ASN1_STRING (struct asn1_string_st) is a fully opaque (incomplete) type, causing compilation errors in the identity and tls_openssl modules.

Details

OpenSSL has been progressively making internal structures opaque. As of OpenSSL 4.0.x (shipped in Fedora 45 / Rawhide), struct asn1_string_st is fully opaque. The identity and tls_openssl modules access ->data and ->length members directly on ASN1_STRING, ASN1_IA5STRING, ASN1_OCTET_STRING, and ASN1_UTCTIME pointers — all typedefs to struct asn1_string_st. This causes hard compilation errors ("invalid use of incomplete typedef") with GCC 16 on Fedora 45.

Affected functions:

  • modules/identity/identity.c: parseX509Date() — accesses dateString->length and dateString->data
  • modules/tls_openssl/openssl_tls_vars.c: openssl_tls_var_alt() — accesses nm->d.ia5->data, nm->d.ia5->length, nm->d.iPAddress->data, nm->d.iPAddress->length

Solution

Replace all direct struct member access with the public accessor API:

  • ->lengthASN1_STRING_length()
  • ->dataASN1_STRING_get0_data()

These accessor functions have been available since OpenSSL 1.1.0 (released 2016), so this change is fully backwards-compatible with all currently supported OpenSSL versions. No #ifdef version guards are needed.

ASN1_STRING_get0_data() returns const unsigned char *, so a (char *) cast is applied where the existing code assigns to char * variables. This preserves the existing behavior.

Compatibility

No backward compatibility issues. The accessor API used in this patch has been the recommended approach since OpenSSL 1.1.0 and works on all OpenSSL versions >= 1.1.0, LibreSSL >= 2.7.0, and BoringSSL.

Closing issues

N/A

OpenSSL 4.x made ASN1_STRING (struct asn1_string_st) an opaque type.
Replace all direct ->data and ->length member access with the public
accessor API (ASN1_STRING_get0_data, ASN1_STRING_length), available
since OpenSSL 1.1.0.

Fixes build on Fedora 45 (OpenSSL 4.x, GCC 16).

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Assisted-by: Claude (Anthropic) <https://claude.ai>
@lemenkov lemenkov force-pushed the openssl_opaque_types branch from 1afb943 to 33f3b79 Compare June 24, 2026 20:41
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.

1 participant