From: "plaisthos (Code Review)"
Date: Tue, 31 Mar 2026 16:24:02 +0000
In-Reply-To:
References:
Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net
Message-ID: <7aab1892181f4b58d6447e4aa12fb6460ec34256-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="nr5IAMbk4Qg="; 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: ,
Cc: openvpn-devel
--nr5IAMbk4Qg=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
plaisthos has uploaded a new patch set (#2). ( http://gerrit.openvpn.net/c/=
openvpn/+/1589?usp=3Demail )
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
---
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/2
diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open=
ssl.c
index 367f81a..558f004 100644
--- a/src/openvpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_openssl.c
@@ -255,17 +255,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
{
@@ -310,8 +312,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: 2
Gerrit-Owner: plaisthos
Gerrit-CC: openvpn-devel
--nr5IAMbk4Qg=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
plaisthos uploaded patch set #2 to this change.
View Change
Do not access internals of ASN1_INTEGER to print hex of serial
O=
penSSL 4.0 does not allow internal access to to these data structures
an=
ymore. So use public methods to get the serial data and convert it to
he=
x.
Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Signed-of=
f-by: Arne Schwabe <arne@...1227...>
---
M src/openvpn/ssl_veri=
fy_openssl.c
1 file changed, 16 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/chang=
es/89/1589/2
diff --git a/src/openvpn/ssl_verify_openssl.c b/src/op=
envpn/ssl_verify_openssl.c
index 367f81a..558f004 100644
--- a/src/openvpn/ssl_verify_openssl.c
+++ b/=
src/openvpn/ssl_verify_openssl.c
@@ -255,17 +255,19 @@
}
else if (strcmp(LN_serialNumber, x5=
09_username_field) =3D=3D 0)
{
- ASN1_INTEGER *asn1_i =3D X509_get_s=
erialNumber(peer_cert);
- struct gc_arena gc =3D gc_new();
- char *serial =3D format_hex_ex(ASN1_STRING_get=
0_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, NU=
LL);
+ char *s=
erial =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
{
@@ -310,8 +3=
12,16 @@
backend_x509_get_serial_hex(openvpn_x509_cert_t *=
cert, struct gc_arena *gc)
{
const AS=
N1_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);=
span>
+ BN_bn2binpad(bn_s=
erial, 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, le=
n_serial, 0, 1, ":", gc);
+ free(buf);
+ BN_free(bn_serial);
+
+ =
return ret;
}
result_t<=
/span>
To view, visit change 1589. To unsubscribe,=
or for help writing mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f5=
20e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...=
27...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
=
--nr5IAMbk4Qg=--