Use ASN1_STRING functions for OpenSSL 4.0 compat#5841
Conversation
|
@claude review. Are these accessors available in previous versions? Have you verified they're available on the minimum version we support. |
|
Claude finished @arr2036's task in 1m 58s —— View job Claude Code Review
Review: OpenSSL Accessor AvailabilityThe short answer is: Minimum supported version
Functions used in this PR
Pre-existing issue in the base branchThe base branch (
This suggests the effective minimum may have already drifted to OpenSSL 1.1.0, even though the configure check still permits 1.0.2. It's worth clarifying whether support for 1.0.x is still a goal. The existing correct pattern (already in the file)The file at #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
const ASN1_STRING *srcasn1p = X509_EXTENSION_get_data(ext);
srcp = ASN1_STRING_get0_data(srcasn1p);
#else
ASN1_STRING *srcasn1p = X509_EXTENSION_get_data(ext);
srcp = ASN1_STRING_data(srcasn1p);
#endifIf 1.0.x support must be preserved, this PR's new uses of Bottom line
|
There was a problem hiding this comment.
Yes, both accessors are safe on supported versions: ASN1_STRING_length has existed since OpenSSL 0.9.x, and ASN1_STRING_get0_data is covered by the existing fallback shim in src/include/missing-h (lines 464-480, gated on HAVE_ASN1_STRING_GET0_DATA from configure). The same pattern is already used elsewhere in tls.c (e.g. lines 2923, 3178, 3185, 3196, 3209, 3303), so this PR is consistent with existing code. Deferring final approval to you since you asked for verification.
Extended reasoning...
Overview
The PR replaces three sets of direct field accesses on ASN1_IA5STRING / ASN1_INTEGER / ASN1_TIME (->data, ->length) with the accessor functions ASN1_STRING_get0_data() and ASN1_STRING_length() in src/main/tls.c. This is needed because OpenSSL 4.0 makes the underlying ASN1_STRING struct opaque, so direct member access stops compiling.
Security risks
None. This is a pure refactor — no behavioral changes, no new allocations, no input validation changes. The new locals (sn_len, sn_data, time_len, time_data) just hoist the accessor calls; the bounds checks against sizeof(buf) are preserved correctly.
Level of scrutiny
Low scrutiny on the code change itself — it's a one-for-one mechanical translation. The only real question is the one the reviewer raised: backward compatibility on the minimum supported OpenSSL.
ASN1_STRING_length()has been part of OpenSSL since 0.9.x — universally available.ASN1_STRING_get0_data()was introduced in OpenSSL 1.1.0, but the project already ships a static-inline fallback insrc/include/missing-h(gated onHAVE_ASN1_STRING_GET0_DATA, set by configure). That shim wrapsASN1_STRING_data()and is already relied upon by ~6 other call sites in this same file (2923, 3178, 3185, 3196, 3209, 3303).
Other factors
The maintainer (arr2036) explicitly asked for version verification rather than just rubber-stamping. Since they engaged directly and asked a specific question, I'm deferring the final approve to them rather than approving over the open question. Once they're satisfied with the answer, this is a trivial merge.
|
@claude what's up with the CI failures? |
|
Claude finished @arr2036's task in 1m 44s —— View job CI Failure Analysis
8 jobs fail, all at "Build FreeRADIUS" with Three specific errors: Note: Two I've prepared a fix commit locally, but I can't push to this fork's branch directly (the GitHub App doesn't have write access to forks). The needed changes are: - if (OCSP_parse_url((char *) ASN1_STRING_get0_data(ad->location->d.ia5), host_out,
+ if (OCSP_parse_url((const char *) ASN1_STRING_get0_data(ad->location->d.ia5), host_out,
- memcpy(buf, (char*) time_data, time_len); // two occurrences
+ memcpy(buf, time_data, time_len);Fix this →%20At%20line%202571%2C%20change%20%22(char%20*)%22%20to%20%22(const%20char%20*)%22%20in%20the%20OCSP_parse_url%20call%3B%202)%20At%20lines%203076%20and%203091%2C%20remove%20the%20%22(char*)%22%20cast%20from%20the%20two%20memcpy(buf%2C%20(char*)%20time_data%2C%20time_len)%20calls%20since%20memcpy%27s%20src%20is%20already%20const%20void*.&repo=FreeRADIUS/freeradius-server) |
|
@claude those seem simple enough, can you fix the const issues. If it goes beyond simple casting and typing, can you come back and ask what the fix is. |
|
Claude finished @arr2036's task in 51s —— View job Const cast fixes
The three fixes are straightforward — here's the diff: - if (OCSP_parse_url((char *) ASN1_STRING_get0_data(ad->location->d.ia5), host_out,
+ if (OCSP_parse_url((const char *) ASN1_STRING_get0_data(ad->location->d.ia5), host_out,
- memcpy(buf, (char*) time_data, time_len); // line ~3076 (notAfter)
+ memcpy(buf, time_data, time_len);
- memcpy(buf, (char*) time_data, time_len); // line ~3091 (notBefore)
+ memcpy(buf, time_data, time_len);
Unfortunately I can't push directly to this fork's branch. You (or the PR author) will need to apply these three changes manually. |
|
@antoniotorresm can you fix the const issues and then we can merge. |
Use ASN1_STRING accessor functions instead of direct field access for ASN1_IA5STRING, ASN1_INTEGER, and ASN1_TIME structures. This fixes compatibility with OpenSSL 4.0. Signed-off-by: Antonio Torres <antorres@redhat.com>
|
Done. |
1817b50 to
fdf4d93
Compare
Use ASN1_STRING accessor functions instead of direct field access for ASN1_IA5STRING, ASN1_INTEGER, and ASN1_TIME structures.
This fixes compatibility with OpenSSL 4.0.