From: "cron2 (Code Review)" Date: Sat, 4 Apr 2026 20:18:47 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Cn1w6P8Qthw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --Cn1w6P8Qthw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. cron2 has uploaded a new patch set (#7) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by flichtenheld Change subject: Do not access internals of ASN1_INTEGER to print hex of ser= ial ...................................................................... Do not access internals of ASN1_INTEGER to print hex of serial OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex. Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589 Message-Id: <20260404155726.7696-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 459.html Signed-off-by: Gert Doering --- M src/openvpn/ssl_verify_openssl.c 1 file changed, 16 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1589/7 diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 96ca1a4..115b8d2 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -260,17 +260,19 @@ } else if (strcmp(LN_serialNumber, x509_username_field) =3D=3D 0) { - ASN1_INTEGER *asn1_i =3D X509_get_serialNumber(peer_cert); - struct gc_arena gc =3D gc_new(); - char *serial =3D format_hex_ex(ASN1_STRING_get0_data(asn1_i), ASN1= _STRING_length(asn1_i), 0, 1 | FHE_CAPS, NULL, &gc); + const ASN1_INTEGER *asn1_i =3D X509_get_serialNumber(peer_cert); + + BIGNUM *bn_serial =3D ASN1_INTEGER_to_BN(asn1_i, NULL); + char *serial =3D BN_bn2hex(bn_serial); + BN_free(bn_serial); if (!serial || cn_len <=3D strlen(serial) + 2) { - gc_free(&gc); + OPENSSL_free(serial); return FAILURE; } snprintf(common_name, cn_len, "0x%s", serial); - gc_free(&gc); + OPENSSL_free(serial); } else { @@ -315,8 +317,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) { const ASN1_INTEGER *asn1_i =3D X509_get_serialNumber(cert); + BIGNUM *bn_serial =3D ASN1_INTEGER_to_BN(asn1_i, NULL); + int len_serial =3D BN_num_bytes(bn_serial); + unsigned char *buf =3D malloc(len_serial); + BN_bn2binpad(bn_serial, buf, len_serial); - return format_hex_ex(ASN1_STRING_get0_data(asn1_i), ASN1_STRING_length= (asn1_i), 0, 1, ":", gc); + char *ret =3D format_hex_ex(buf, len_serial, 0, 1, ":", gc); + free(buf); + BN_free(bn_serial); + + return ret; } result_t -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30 Gerrit-Change-Number: 1589 Gerrit-PatchSet: 7 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld --Cn1w6P8Qthw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld.

cron2 uploaded patch set #7 to the change originally cr= eated by plaisthos.

View Change

The following approvals got outdate= d and were removed: Code-Review+2 by flichtenheld

Do not access internals of A=
SN1_INTEGER to print hex of serial

OpenSSL 4.0 does not allow intern= al access to to these data structures
anymore. So use public methods to = get the serial data and convert it to
hex.

Change-Id: I5158fbb076= 2443ea4954e5745f520e83e019ed30
Signed-off-by: Arne Schwabe <arne@...1386...= 227...>
Acked-by: Frank Lichtenheld <frank@...2641...>
Gerri= t URL: https://gerrit.openvpn.net/c/openvpn/+/1589
Message-Id: <20260= 404155726.7696-1-gert@...1296...>
URL: https://www.mail-archive.com/o= penvpn-devel@lists.sourceforge.net/msg36459.html
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M src/openvpn/ssl_verify_openssl.c1 file changed, 16 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1589/7<=
/pre>
-        ASN1_INTEGER *asn1_i =3D X509_get_serialNumber(pee=
r_cert);
- struc= t gc_arena gc =3D gc_new();
- char *serial =3D format_hex_ex(ASN1_STRING_get0_data(asn1_i),= ASN1_STRING_length(asn1_i), 0, 1 | FHE_CAPS, NULL, &gc);
+ const ASN1_INTEGER *asn1_= i =3D X509_get_serialNumber(peer_cert);
+
= + BIGNUM *bn_serial =3D ASN1_INTEGER_to_BN(asn1_i, NULL);
= + char *serial =3D BN_bn= 2hex(bn_serial);
+ = BN_free(bn_serial);

if (!se= rial || cn_len <=3D strlen(serial) + 2)
{
- gc_free(&gc= );
+ OPENS= SL_free(serial);
return FAILURE;
}

snprintf(common_name, cn_len, "= 0x%s", serial);
- = gc_free(&gc);
+ OPENSSL_free(serial);
}
= else
{
@@ -315,8 +317,16 @@=
backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc= _arena *gc)
{
const ASN1_INTEGER *asn= 1_i =3D X509_get_serialNumber(cert);
+ BIGNUM *bn_serial =3D ASN1_INTEGER_to_BN(asn1_i, NULL)= ;
+ int len_serial= =3D BN_num_bytes(bn_serial);
+ unsigned char *buf =3D malloc(len_serial);
+ BN_bn2binpad(bn_serial, buf, len_s= erial);

- return format_hex_ex(ASN1_STRING_get0_data(asn1_i), ASN1_STRING_len= gth(asn1_i), 0, 1, ":", gc);
+ char *ret =3D format_hex_ex(buf, len_serial, 0, 1, &= quot;:", gc);
+ = free(buf);
+ BN= _free(bn_serial);
+
+ return ret;
}

result_t
<= /span>

To view, visit change 1589. To unsubscribe, or for help writ= ing mail filters, visit settings.

=
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f5= 20e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --Cn1w6P8Qthw=--