Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70A5EC982DA for ; Sun, 20 Sep 2026 17:22:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 3F45F4052F; Sun, 20 Sep 2026 17:22:19 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zZvDUfIyFASe; Sun, 20 Sep 2026 17:22:17 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org B482A4106F Authentication-Results: smtp4.osuosl.org; arc=fail smtp.remote-ip=140.211.166.142 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=fail; t=1789924937; b=mTRR/FZW2i+qOL/Uy+rK6IDNSC5D0V+UY1tNM6339kFZl4uGpByreEpwr8YOU4Xkw2Bn fXNynAt9vx/Dw+oXlgCcvLX5w+t5QGopSTSyqf2n7/4c6IJwNC4mK8Saq157GAObZo3as WAV0ptCfcHdYlnUp5UGg++z0S/Y7r7lbpYegruIvydY+hCTuDPjm0nwYKKGY1EUyYpmzy ZMYnbYpNxPZSBZqaoIAcgT6vHIpZU13MStbcXlSlFvS2pkaeq8Cst1dak1GratP1lpTGZ PILR/NsxH6DPT32gYf9FrBeGA73iwZozM+QbLRxY5twz6Zl8WovUGXgKOguevbnkTQw== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1789924937; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received: DKIM-Signature:X-KAS-Sym:Received:Received:From:To:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:X-Spamd-Bar:Subject: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Cc:Content-Type: Content-Transfer-Encoding:Errors-To:Sender; bh=aOZaAPaoDUu3vp1ZSb4N6SyebkGK02fFyavprPvbI/s=; b=YRkhKgOHJbU38NqnIwYo68a8czQ8YjJmhcrOgK+geMu2ZCSoG3VVNKfHV9YvdGsgsCKs C1ur6IXQhWDm+Gs1bZCIlTi15sO8WpMBJfpidyXNYVVtWEfYlij4f31lcOYSIqDGUEl36 WdsiV7fKdovYfGkE8RCoBpq/blGPfXKlolSQU44JjWHZVTN1dL1AVoGQ3bFccZz/jIrNN H34zcuBCINX3QUrXIVIO60UoUZ7Pl1q9AbDgg4oFJMWwhcuuvbrFWMcoJpMGNKTXDrRg4 i8TomSL714Lcth+IZYTn8i/KRlShwFGvQyeMGYQj/BlYHDwOT1H13gfY3zqmp/1asOg== ARC-Authentication-Results: i=2; smtp4.osuosl.org; arc=fail smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=buildroot.org; s=default; t=1789924937; bh=aOZaAPaoDUu3vp1ZSb4N6SyebkGK02fFyavprPvbI/s=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=eE3hVHnxoy+fd2gHShtpi7ksCJOU+rsjS6H/dIYMoOoFZLmmH6x388YsbOMOBAXoS zCt5LEDhxwbera4r/kL3q0TQyyq2ZUfiyipvpVMcPBJ7jrYsVK/hmEAS1QqxsAHVWI KZNc7HPGpr8aNBN4dinIT6FJF8PGX+/TJjH2yvJC9df7fYnwGC2HS/Uv3V5orczNYC bR2g3AV243qcW8TlP5ABZhSXv5lixPE4HXji37MuTNS1ck10a/k3X26K4m/CW0g0N7 FV7xFD5oG3DcN12ZeeSi+O0d8//kjoYLHO7fl4WJhpn6rUVtYkX6Cl5o516gPiR8Kt FcTJECCcnEyiA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id B482A4106F; Sun, 20 Sep 2026 17:22:17 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id 92F5B3FA for ; Sun, 20 Sep 2026 17:22:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 78A8B80D74 for ; Sun, 20 Sep 2026 17:22:15 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VRFMTXAiSnZs for ; Sun, 20 Sep 2026 17:22:14 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org CAE5C80D0F Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=85.13.140.57 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1789924934; b=OB3MN2bc7/GAMx4Wp95Jb0E9EkTogxt+GcnxxA/F7rSO9cmJtvnZMxpIMz1m77Ysca1N PFDGN3ALiWMWf0yADVG3Ap6WEchbkLZfmdOjvV9d2M7DG0xTRNv37C7cfNXwE9w+rFEZt CIj278nvlqjT97UhL6SfizQORigHgLUooBTw6SXP+3j+4E4G3zCTRJpbNTlA8WxOzWiEo CYox2l+0qQfzIKveT1zLx+gcd18/Id28EBiSnRgN8TfR+qDpFYS2oUY6LXWTkqeNVt5LQ L85iJ+HSlhsSFqp1kr/Mn7F0Q4N9aQ4cjNxzCfV1Mjr79IVZiKXNc4GKlXs6N2zuHFQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1789924934; h=Received-SPF:DKIM-Signature:X-KAS-Sym:Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Score:X-Spamd-Bar; bh=0UNFLQmWWaDo+6KsJ5KF7DS7cJA+hqLv/9gCwAg2G/A=; b=O3UVBC24aozcEPCvvxO+tiyWVpHlR6JEf1zWOHCGbvzY1Fv5Lv6R3NvUd1I2u9NhiyTy PTW0uL5MpQyPClgF/5WIIyQMQVPPwD5WD1EhVa8/EAEDXtqVZQgKI62ESxxnG52qxkgfB MG+TEE1eyut71aKM3EoHSiHZIbhjoSoxALdW4zseQ9LshgY1PwDeg/nrtkWmXQ5jrY4CD JCDk7yHObUBJaovnT3AZ/NBkRbykTen8QA+LwrEyJuv+D1GotLp2KhRRUe6JtXVD6exN5 FDV9Ukx+o5yh4nTAlz792EtZ7FfHjk4HPvQiIrPPATw04QCHMqA3KAmQytoYAIIvzxg== ARC-Authentication-Results: i=1; smtp1.osuosl.org; dmarc=pass header.from=kuhls.net; dkim=pass header.d=kuhls.net header.i=@kuhls.net header.a=rsa-sha256 header.s=kas202605290044 header.b=KOSIalX5; arc=none smtp.remote-ip=85.13.140.57 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=85.13.140.57; helo=dd20012.kasserver.com; envelope-from=bernd@kuhls.net; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=kuhls.net Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=kuhls.net header.i=@kuhls.net header.a=rsa-sha256 header.s=kas202605290044 header.b=KOSIalX5 Received: from dd20012.kasserver.com (dd20012.kasserver.com [85.13.140.57]) by smtp1.osuosl.org (Postfix) with ESMTPS id CAE5C80D0F for ; Sun, 20 Sep 2026 17:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kuhls.net; s=kas202605290044; t=1789924169; bh=0UNFLQmWWaDo+6KsJ5KF7DS7cJA+hqLv/9gCwAg2G/A=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=KOSIalX5kwMO8npmPG8CGgqnxNL8ykD4C585hPw9smh9Jr8FIbapTWhl2kH4OY6Rz WwfxrVeE42n5lOXkVDeFCyMkn3isIFvMJBbGAQur1RCR5clUUPdlOGgkLl9Ip2QDWk AdCha30nUOl2WCStC39Kfd9SDTyiZ/RRd122rXyiVbXocGWtlYQ/rUTy1ubyb6WBht /ZssQxh5db4Vq+Pbzwi85nvbNQ3z25ToqCTR0H1e54uvAEpc7jcLf2+pOx145esF5K Ws8Lqmlkw8cgHUv3G+/HKrdB8/k8GN4/xGhq4lt3p74dIpGdmzHgbh6qNqG/R02UyL bmSMb03kD4JAQ== X-KAS-Sym: v3:f51bdf72230551df:lHdkWXAlOH3mFYa7MPhN/Q5mZRaSllnUONUXNce4VNqCbu40d29sJoTMWL/UgPpKmiu+oFAK+SGKiz0pvNPHzzdK8865J0NZZhjD1YGG6aDHJWSqGt9pmYaVeClFza2NY+i+npE0hJgg/gHxSjO6xcwlUb6QQuNPO0hdPziIw4dhYYf4DJSWrRRzANCMomoD/RZTgi346Zz0eW33G9Vcp3B7DR+EaybhZMrqLCjEqGCkGFXPOjSjpT0/ayWciGjXWUz3QuiXUZXlIr+lNW1V5S5HyBJCR/w6EnvHAsYJhPTQhQAx4gJVctdz4XTCaIimRq6ACwja3Rp9OR6uCM1UuQ==:JdXFonGyeZrp73YWjimPL0pjwE323SQ6PprZlDWEnGO84pGUQ1gqO57Sa9aVTaPwe8tK8caJbyNMseFEdhaDjiI2beQZqtMZcB/6GrC3WCbUEdKAkDLwpbuFJLSvjb2pM9dGIA8sNNVMTvbJWkPP5eyGXRxvZA7n2Z4IOt8YR7+ZqcbTmfw9Mo6dcoYMvUtm3vXVjScl8S2wvtWr/MXGFZAGz0LxUKMA+CbTB2olF//cJA0XO+LuJi9KzlyoZqqvgIknhTfXs/MMgXv3xFJOgVz2MK9Ud8HEXH2eDTraJN2avCkFROF2uVEOCCCNSvHYSpNIOqXWNgVmtwC3JMjkXcZKNF9hFFjlyTdGvKNg7bPxMGS6+0jzOUis8HKu91YLw6xvVHNij0CHFzkOsJ9f/QOMPFFjj3qZjm/uSHN+6wbjuS9/PVdkTrz7PbrLbNy0HILUR9/A4ZIVK7SuBlV/wRNCFmKDlsOqfgtGyRCxNXwX0+fuYu0N+78o5RpRYI8GK8FAUjy535LLfi6Sc9vglk4Leqsvr0FKKp00DSJJ/LWHy8JDmV++1bwpri1JC9k4Lz+9Jfc2wDVaCmbn0GveNY4yinhzDh1ZutP8AzZV9HPtnq om3nqQ78Wbry3d9fmMa/C52ZGhlVoIDDYvpRUf07IkcaB3ZD35u0R6Hkz8wIGTuIfZ95+W1IqzulTNvy74AKMb/ZyUc0Uksei0fK64MyQD0CjO+WPaYLkUP/jFy3oyGZpa7k8meBtmFDrN/kFf49j8WWhnfxs= Received: from fli4l.lan.fli4l (p54a1b276.dip0.t-ipconnect.de [84.161.178.118]) by dd20012.kasserver.com (Postfix) with ESMTPSA id 7741FA4C48AA; Sun, 20 Sep 2026 19:09:29 +0200 (CEST) Received: from bruckner.lan.fli4l ([192.168.1.1]:57728) by fli4l.lan.fli4l with esmtp (Exim 4.100.1) (envelope-from ) id 1x8L1f-000000000o7-3Qsa; Sun, 20 Sep 2026 17:08:28 +0000 From: Bernd Kuhls To: buildroot@buildroot.org Date: Sun, 20 Sep 2026 19:08:04 +0200 Message-ID: <20260920170815.240247-58-bernd@kuhls.net> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260920170815.240247-1-bernd@kuhls.net> References: <20260920170815.240247-1-bernd@kuhls.net> MIME-Version: 1.0 X-Spamd-Bar: / Subject: [Buildroot] [PATCH v5 57/67] package/squid: Fix build with OpenSSL 4.0.0 X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zoltan Gyarmati , Marcin Bis , Robert Rose , Yair Ben Avraham , Angelo Compagnucci , Thomas Petazzoni , =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= , Heiko Thiery , Philipp Richter , Titouan Christophe , Fabrice Fontaine , Joris Lijssens , Thomas Devoogdt , Romain Naour , Roy Kollen Svendsen , Brandon Maier , Francois Perrad , =?UTF-8?q?No=C3=A9=20Rubinstein?= , Norbert Lange , Jesse Van Gavere , Luca Ceresoli , David GOUARIN , Andrey Yurovsky , =?UTF-8?q?Andr=C3=A9=20Zwing?= , Daniel Price , Christian Hitz , Gregory Dymarek , Stefan Ott , Baxiche Su , Philippe Reynes , Sen Hastings , Fabrice Fontaine , James Hilliard , Giulio Benetti , Karoly Kasza , Martin Bark Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Signed-off-by: Bernd Kuhls --- .../0001-Fix-OpenSSL-4.0-compatibility.patch | 368 ++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 package/squid/0001-Fix-OpenSSL-4.0-compatibility.patch diff --git a/package/squid/0001-Fix-OpenSSL-4.0-compatibility.patch b/package/squid/0001-Fix-OpenSSL-4.0-compatibility.patch new file mode 100644 index 0000000000..38fc0c4a04 --- /dev/null +++ b/package/squid/0001-Fix-OpenSSL-4.0-compatibility.patch @@ -0,0 +1,368 @@ +From 144a59fec3d7a4bd7f0c3e71934156e1a56ebabc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= +Date: Wed, 6 May 2026 17:18:58 +0200 +Subject: [PATCH] Fix OpenSSL 4.0 compatibility + +Replace direct ASN1 structure field access with accessor functions. +and use ASN1_STRING_set() instead of direct field assignment. + +Fix issues caused by X509* API constness changes; in some cases, +casting the const away is necessary to keep compatibility with +OpenSSL 3. + +Downloaded from Fedora: +https://src.fedoraproject.org/rpms/squid/blob/rawhide/f/squid-7.5-openssl4.patch + +Upstream: https://github.com/squid-cache/squid/pull/2389#issuecomment-5554800393 + +Signed-off-by: Bernd Kuhls +--- + .../cert_generators/file/certificate_db.cc | 2 +- + src/ssl/gadgets.cc | 92 +++++++++++-------- + src/ssl/gadgets.h | 4 +- + src/ssl/support.cc | 18 ++-- + 4 files changed, 66 insertions(+), 50 deletions(-) + +diff --git a/src/security/cert_generators/file/certificate_db.cc b/src/security/cert_generators/file/certificate_db.cc +index 4b729b316..35849aa63 100644 +--- a/src/security/cert_generators/file/certificate_db.cc ++++ b/src/security/cert_generators/file/certificate_db.cc +@@ -335,7 +335,7 @@ Ssl::CertificateDb::addCertAndPrivateKey(std::string const &useKey, const Securi + } + + const auto tm = X509_getm_notAfter(cert.get()); +- row.setValue(cnlExp_date, std::string(reinterpret_cast(tm->data), tm->length).c_str()); ++ row.setValue(cnlExp_date, std::string(reinterpret_cast(ASN1_STRING_get0_data(tm)), ASN1_STRING_length(tm)).c_str()); + const auto subject = OneLineSummary(*X509_get_subject_name(cert.get())); + row.setValue(cnlName, subject.get()); + row.setValue(cnlKey, useKey.c_str()); +diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc +index 06b8b79dd..100ee6a46 100644 +--- a/src/ssl/gadgets.cc ++++ b/src/ssl/gadgets.cc +@@ -259,20 +259,31 @@ static bool replaceCommonName(Security::CertPointer & cert, std::string const &r + if (cn.length() > 2 && *cn.begin() == '[' && *cn.rbegin() == ']') + cn = cn.substr(1, cn.size()-2); + +- X509_NAME *name = X509_get_subject_name(cert.get()); ++ const X509_NAME *subject = X509_get_subject_name(cert.get()); ++ if (!subject) ++ return false; ++ ++ X509_NAME *name = X509_NAME_dup(subject); + if (!name) + return false; ++ + // Remove the CN part: + int loc = X509_NAME_get_index_by_NID(name, NID_commonName, -1); +- if (loc >=0) { +- X509_NAME_ENTRY *tmp = X509_NAME_get_entry(name, loc); +- X509_NAME_delete_entry(name, loc); ++ if (loc >= 0) { ++ X509_NAME_ENTRY *tmp = X509_NAME_delete_entry(name, loc); + X509_NAME_ENTRY_free(tmp); + } + + // Add a new CN +- return X509_NAME_add_entry_by_NID(name, NID_commonName, MBSTRING_ASC, +- (unsigned char *)(cn.c_str()), -1, -1, 0); ++ if (!X509_NAME_add_entry_by_NID(name, NID_commonName, MBSTRING_ASC, ++ (unsigned char *)(cn.c_str()), -1, -1, 0)) { ++ X509_NAME_free(name); ++ return false; ++ } ++ ++ int ret = X509_set_subject_name(cert.get(), name); ++ X509_NAME_free(name); ++ return ret; + } + + const char *Ssl::CertSignAlgorithmStr[] = { +@@ -301,9 +312,9 @@ static void + printX509Signature(const Security::CertPointer &cert, std::string &out) + { + const ASN1_BIT_STRING *sig = Ssl::X509_get_signature(cert); +- if (sig && sig->data) { +- const unsigned char *s = sig->data; +- for (int i = 0; i < sig->length; ++i) { ++ if (sig && ASN1_STRING_get0_data(sig)) { ++ const unsigned char *s = ASN1_STRING_get0_data(sig); ++ for (int i = 0; i < ASN1_STRING_length(sig); ++i) { + char hex[3]; + snprintf(hex, sizeof(hex), "%02x", s[i]); + out.append(hex); +@@ -377,7 +388,7 @@ mimicAuthorityKeyId(Security::CertPointer &cert, Security::CertPointer const &mi + X509_EXTENSION *ext; + // Check if the issuer has the Subject Key Identifier extension + const int indx = X509_get_ext_by_NID(issuerCert.get(), NID_subject_key_identifier, -1); +- if (indx >= 0 && (ext = X509_get_ext(issuerCert.get(), indx))) { ++ if (indx >= 0 && (ext = const_cast(X509_get_ext(issuerCert.get(), indx)))) { + issuerKeyId.reset((ASN1_OCTET_STRING *)X509V3_EXT_d2i(ext)); + } + } +@@ -418,8 +429,7 @@ mimicAuthorityKeyId(Security::CertPointer &cert, Security::CertPointer const &mi + unsigned char *ext_der = nullptr; + int ext_len = ASN1_item_i2d((ASN1_VALUE *)theAuthKeyId.get(), &ext_der, ASN1_ITEM_ptr(method->it)); + Ssl::ASN1_OCTET_STRING_Pointer extOct(ASN1_OCTET_STRING_new()); +- extOct.get()->data = ext_der; +- extOct.get()->length = ext_len; ++ ASN1_STRING_set(extOct.get(), ext_der, ext_len); + Ssl::X509_EXTENSION_Pointer extAuthKeyId(X509_EXTENSION_create_by_NID(nullptr, NID_authority_key_identifier, 0, extOct.get())); + if (!extAuthKeyId.get()) + return false; +@@ -471,7 +481,7 @@ mimicExtensions(Security::CertPointer & cert, Security::CertPointer const &mimic + int nid; + for (int i = 0; (nid = extensions[i]) != 0; ++i) { + const int pos = X509_get_ext_by_NID(mimicCert.get(), nid, -1); +- if (X509_EXTENSION *ext = X509_get_ext(mimicCert.get(), pos)) { ++ if (X509_EXTENSION *ext = const_cast(X509_get_ext(mimicCert.get(), pos))) { + // Mimic extension exactly. + if (X509_add_ext(cert.get(), ext, -1)) + ++added; +@@ -482,7 +492,7 @@ mimicExtensions(Security::CertPointer & cert, Security::CertPointer const &mimic + // that the more stringent requirements are met. + + const int p = X509_get_ext_by_NID(cert.get(), NID_key_usage, -1); +- if ((ext = X509_get_ext(cert.get(), p)) != nullptr) { ++ if ((ext = const_cast(X509_get_ext(cert.get(), p))) != nullptr) { + ASN1_BIT_STRING *keyusage = (ASN1_BIT_STRING *)X509V3_EXT_d2i(ext); + ASN1_BIT_STRING_set_bit(keyusage, KeyEncipherment, 1); + +@@ -495,8 +505,7 @@ mimicExtensions(Security::CertPointer & cert, Security::CertPointer const &mimic + (const ASN1_ITEM *)ASN1_ITEM_ptr(method->it)); + + ASN1_OCTET_STRING *ext_oct = ASN1_OCTET_STRING_new(); +- ext_oct->data = ext_der; +- ext_oct->length = ext_len; ++ ASN1_STRING_set(ext_oct, ext_der, ext_len); + X509_EXTENSION_set_data(ext, ext_oct); + + ASN1_OCTET_STRING_free(ext_oct); +@@ -518,7 +527,7 @@ mimicExtensions(Security::CertPointer & cert, Security::CertPointer const &mimic + SBuf + Ssl::AsnToSBuf(const ASN1_STRING &buffer) + { +- return SBuf(reinterpret_cast(buffer.data), buffer.length); ++ return SBuf(reinterpret_cast(ASN1_STRING_get0_data(&buffer)), ASN1_STRING_length(&buffer)); + } + + /// OpenSSL ASN1_STRING_to_UTF8() wrapper +@@ -547,7 +556,7 @@ Ssl::ParseAsSimpleDomainNameOrIp(const SBuf &text) + } + + std::optional +-Ssl::ParseCommonNameAt(X509_NAME &name, const int cnIndex) ++Ssl::ParseCommonNameAt(const X509_NAME &name, const int cnIndex) + { + const auto cn = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(&name, cnIndex)); + if (!cn) { +@@ -576,7 +585,7 @@ Ssl::ParseCommonNameAt(X509_NAME &name, const int cnIndex) + static bool + addAltNameWithSubjectCn(Security::CertPointer &cert) + { +- X509_NAME *name = X509_get_subject_name(cert.get()); ++ const X509_NAME *name = X509_get_subject_name(cert.get()); + if (!name) + return false; + +@@ -610,7 +619,7 @@ static bool buildCertificate(Security::CertPointer & cert, Ssl::CertificatePrope + // returns a pointer to the existing subject name. Nothing to clean here. + if (properties.mimicCert.get()) { + // Leave subject empty if we cannot extract it from true cert. +- if (X509_NAME *name = X509_get_subject_name(properties.mimicCert.get())) { ++ if (const X509_NAME *name = X509_get_subject_name(properties.mimicCert.get())) { + // X509_set_subject_name will call X509_dup for name + X509_set_subject_name(cert.get(), name); + } +@@ -656,7 +665,7 @@ static bool buildCertificate(Security::CertPointer & cert, Ssl::CertificatePrope + bool useCommonNameAsAltName = true; + // mimic the alias and possibly subjectAltName + if (properties.mimicCert.get()) { +- unsigned char *alStr; ++ const unsigned char *alStr; + int alLen; + alStr = X509_alias_get0(properties.mimicCert.get(), &alLen); + if (alStr) { +@@ -667,7 +676,7 @@ static bool buildCertificate(Security::CertPointer & cert, Ssl::CertificatePrope + // certificates with CN unrelated to subjectAltNames. + if (!properties.setCommonName) { + int pos = X509_get_ext_by_NID(properties.mimicCert.get(), NID_subject_alt_name, -1); +- X509_EXTENSION *ext=X509_get_ext(properties.mimicCert.get(), pos); ++ X509_EXTENSION *ext = const_cast(X509_get_ext(properties.mimicCert.get(), pos)); + if (ext) { + if (X509_add_ext(cert.get(), ext, -1)) + ++addedExtensions; +@@ -922,20 +931,23 @@ Ssl::WritePrivateKey(Ssl::BIO_Pointer &bio, const Security::PrivateKeyPointer &p + } + + Ssl::UniqueCString +-Ssl::OneLineSummary(X509_NAME &name) ++Ssl::OneLineSummary(const X509_NAME &name) + { + return Ssl::UniqueCString(X509_NAME_oneline(&name, nullptr, 0)); + } + + bool Ssl::sslDateIsInTheFuture(char const * date) + { +- ASN1_UTCTIME tm; +- tm.flags = 0; +- tm.type = 23; +- tm.data = (unsigned char *)date; +- tm.length = strlen(date); +- +- return (X509_cmp_current_time(&tm) > 0); ++ ASN1_UTCTIME *tm = ASN1_UTCTIME_new(); ++ if (!tm) ++ return false; ++ if (!ASN1_UTCTIME_set_string(tm, date)) { ++ ASN1_UTCTIME_free(tm); ++ return false; ++ } ++ int result = X509_cmp_current_time(tm); ++ ASN1_UTCTIME_free(tm); ++ return (result > 0); + } + + /// Print the time represented by a ASN1_TIME struct to a string using GeneralizedTime format +@@ -945,14 +957,18 @@ static bool asn1timeToGeneralizedTimeStr(ASN1_TIME *aTime, char *buf, int bufLen + // UTCTime has the form YYMMDDHHMMSS[Z | [+|-]offset] + // GeneralizedTime has the form YYYYMMDDHHMMSS[Z | [+|-] offset] + ++ const unsigned char *data = ASN1_STRING_get0_data(aTime); ++ int length = ASN1_STRING_length(aTime); ++ int type = ASN1_STRING_type(aTime); ++ + // length should have space for data plus 2 extra bytes for the two extra year fields + // plus the '\0' char. +- if ((aTime->length + 3) > bufLen) ++ if ((length + 3) > bufLen) + return false; + + char *str; +- if (aTime->type == V_ASN1_UTCTIME) { +- if (aTime->data[0] > '5') { // RFC 2459, section 4.1.2.5.1 ++ if (type == V_ASN1_UTCTIME) { ++ if (data[0] > '5') { // RFC 2459, section 4.1.2.5.1 + buf[0] = '1'; + buf[1] = '9'; + } else { +@@ -960,11 +976,11 @@ static bool asn1timeToGeneralizedTimeStr(ASN1_TIME *aTime, char *buf, int bufLen + buf[1] = '0'; + } + str = buf +2; +- } else // if (aTime->type == V_ASN1_GENERALIZEDTIME) ++ } else // if (type == V_ASN1_GENERALIZEDTIME) + str = buf; + +- memcpy(str, aTime->data, aTime->length); +- str[aTime->length] = '\0'; ++ memcpy(str, data, length); ++ str[length] = '\0'; + return true; + } + +@@ -996,8 +1012,8 @@ bool Ssl::certificateMatchesProperties(X509 *cert, CertificateProperties const & + return true; + + if (!properties.setCommonName) { +- X509_NAME *cert1_name = X509_get_subject_name(cert); +- X509_NAME *cert2_name = X509_get_subject_name(cert2); ++ const X509_NAME *cert1_name = X509_get_subject_name(cert); ++ const X509_NAME *cert2_name = X509_get_subject_name(cert2); + if (X509_NAME_cmp(cert1_name, cert2_name) != 0) + return false; + } else if (properties.commonName != CommonHostName(cert)) +diff --git a/src/ssl/gadgets.h b/src/ssl/gadgets.h +index e0c60c3a3..4c487596b 100644 +--- a/src/ssl/gadgets.h ++++ b/src/ssl/gadgets.h +@@ -160,7 +160,7 @@ bool WriteX509Certificate(BIO_Pointer &bio, const Security::CertPointer & cert); + bool WritePrivateKey(BIO_Pointer &bio, const Security::PrivateKeyPointer &pkey); + + /// a RAII wrapper for the memory-allocating flavor of X509_NAME_oneline() +-UniqueCString OneLineSummary(X509_NAME &); ++UniqueCString OneLineSummary(const X509_NAME &); + + /** + \ingroup SslCrtdSslAPI +@@ -285,7 +285,7 @@ const char *CommonHostName(X509 *x509); + SBuf AsnToSBuf(const ASN1_STRING &); + + /// interprets X.509 Subject or Issuer name entry (at the given position) as CN +-std::optional ParseCommonNameAt(X509_NAME &, int); ++std::optional ParseCommonNameAt(const X509_NAME &, int); + + /// interprets the given buffer as either a textual representation of an IP + /// address (if possible) or a domain name without wildcard support (otherwise) +diff --git a/src/ssl/support.cc b/src/ssl/support.cc +index e7872035c..09f268a7e 100644 +--- a/src/ssl/support.cc ++++ b/src/ssl/support.cc +@@ -272,23 +272,23 @@ ParseSubjectAltName(const GENERAL_NAME &san) + + // RFC 5280 section 4.2.1.6 signals IPv4/IPv6 address family using data length + +- if (san.d.iPAddress->length == 4) { ++ if (ASN1_STRING_length(san.d.iPAddress) == 4) { + struct in_addr addr; + static_assert(sizeof(addr.s_addr) == 4); +- memcpy(&addr.s_addr, san.d.iPAddress->data, sizeof(addr.s_addr)); ++ memcpy(&addr.s_addr, ASN1_STRING_get0_data(san.d.iPAddress), sizeof(addr.s_addr)); + const Ip::Address ip(addr); + return AnyP::Host::ParseIp(ip); + } + +- if (san.d.iPAddress->length == 16) { ++ if (ASN1_STRING_length(san.d.iPAddress) == 16) { + struct in6_addr addr; + static_assert(sizeof(addr.s6_addr) == 16); +- memcpy(&addr.s6_addr, san.d.iPAddress->data, sizeof(addr.s6_addr)); ++ memcpy(&addr.s6_addr, ASN1_STRING_get0_data(san.d.iPAddress), sizeof(addr.s6_addr)); + const Ip::Address ip(addr); + return AnyP::Host::ParseIp(ip); + } + +- debugs(83, 3, "unexpected length of an IP address SAN: " << san.d.iPAddress->length); ++ debugs(83, 3, "unexpected length of an IP address SAN: " << ASN1_STRING_length(san.d.iPAddress)); + return std::nullopt; + } + +@@ -856,7 +856,7 @@ Ssl::InitClientContext(Security::ContextPointer &ctx, Security::PeerOptions &pee + + /// \ingroup ServerProtocolSSLInternal + static const char * +-ssl_get_attribute(X509_NAME * name, const char *attribute_name) ++ssl_get_attribute(const X509_NAME * name, const char *attribute_name) + { + static char buffer[1024]; + buffer[0] = '\0'; +@@ -879,7 +879,7 @@ ssl_get_attribute(X509_NAME * name, const char *attribute_name) + const char * + Ssl::GetX509UserAttribute(X509 * cert, const char *attribute_name) + { +- X509_NAME *name; ++ const X509_NAME *name; + const char *ret; + + if (!cert) +@@ -933,7 +933,7 @@ const char * + Ssl::GetX509CAAttribute(X509 * cert, const char *attribute_name) + { + +- X509_NAME *name; ++ const X509_NAME *name; + const char *ret; + + if (!cert) +@@ -1484,7 +1484,7 @@ void Ssl::InRamCertificateDbKey(const Ssl::CertificateProperties &certProperties + if (certProperties.mimicCert) { + if (auto *sig = Ssl::X509_get_signature(certProperties.mimicCert)) { + origSignatureAsKey = true; +- key.append((const char *)sig->data, sig->length); ++ key.append((const char *)ASN1_STRING_get0_data(sig), ASN1_STRING_length(sig)); + } + } + +-- +2.47.3 + -- 2.47.3 _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot