Fix build with OpenSSL 4.x: replace direct ASN1_STRING member access#3956
Open
lemenkov wants to merge 1 commit into
Open
Fix build with OpenSSL 4.x: replace direct ASN1_STRING member access#3956lemenkov wants to merge 1 commit into
lemenkov wants to merge 1 commit into
Conversation
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>
1afb943 to
33f3b79
Compare
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.
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 theidentityandtls_opensslmodules.Details
OpenSSL has been progressively making internal structures opaque. As of OpenSSL 4.0.x (shipped in Fedora 45 / Rawhide),
struct asn1_string_stis fully opaque. Theidentityandtls_opensslmodules access->dataand->lengthmembers directly onASN1_STRING,ASN1_IA5STRING,ASN1_OCTET_STRING, andASN1_UTCTIMEpointers — all typedefs tostruct 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()— accessesdateString->lengthanddateString->datamodules/tls_openssl/openssl_tls_vars.c:openssl_tls_var_alt()— accessesnm->d.ia5->data,nm->d.ia5->length,nm->d.iPAddress->data,nm->d.iPAddress->lengthSolution
Replace all direct struct member access with the public accessor API:
->length→ASN1_STRING_length()->data→ASN1_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
#ifdefversion guards are needed.ASN1_STRING_get0_data()returnsconst unsigned char *, so a(char *)cast is applied where the existing code assigns tochar *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