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 28284C982E1 for ; Sun, 20 Sep 2026 14:55:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E7CD540E60; Sun, 20 Sep 2026 14:55:45 +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 6NLSmIKIy1qb; Sun, 20 Sep 2026 14:55:44 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org 1A20440E6D 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=1789916144; b=SHpu0EdpEhfNUWLmBmxqI3Ay/3uiMbIIgt/GA56ryHT2nPfIGkqhNFooXJHyZBJWuJFy +BrbYIHLEYDjblMUJcey5RKNpCYbrLuPS6r4AnvrJ2bfEaQtckzkyhOnK1VDarOi1Ko/z dUWWRSVKqwDIjhCqIpTm5q6MQPDD/FJk/KlbNZaYnntfWei9z+Qe6HXw+9Xf94idIdvYQ 59T5LKMWCXI/lyh7VEqBIawF29I35vibqS3ML4NmsNxQOknjM4mC80OO5S4NK5FN8IG+7 6SASGC3UqSk9mV3pd0qsc0KjQCE6H6wmqsGFZRA+yBs+H11FjiMX2Qjt1ML+0U2K5rw== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1789916144; 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:Content-Type: Content-Transfer-Encoding:Errors-To:Sender; bh=aOZaAPaoDUu3vp1ZSb4N6SyebkGK02fFyavprPvbI/s=; b=g+10vpELc81WFfmp0vR4LA0SkllxfYq1wiXDaLP8xOxiG4Qbjc1XAVyRa4jZ40jvRiH8 0d+HiKb93CyvN0XJnw2Itbp0sJDbZrlN+YrF1PnZdtGpDW6SUn0v1HUO3aSFcnFIQ/vwd 54Mmpg0VVQ0WlPZzv8183spT+mksqgvaCUYZhnpTSouTwlzlTLYJJUkLRSIQU6uxwArDA tkxS4msR6pAB7QOfwxpJETa7rR/WlUlDj6/12t8eD/Xdz1IWPLopRX2LqlhyZ9nL28h0R q+rrvI/7aQj3nBWiRJoXCv27653fdW84nmhfLAGY5bajTjINoHZHXe6I3O78GvhZ9fg== 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=1789916144; bh=aOZaAPaoDUu3vp1ZSb4N6SyebkGK02fFyavprPvbI/s=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YkuVpK3FyC0aipLOZYUXd/rKjF+nrQBxe1XmiUz3OUKy3eQaO7l9enAYLLdJPpuxT 4EUpjXcRI/YaymnRfW/SYTk8ow/9ChyZ83CZrPOcjpAdQhf2mHw22kbAM5L0YFmYPI uKZUoo1qUICFydNwCJQ/FQxmyPhSmAlmRTHhJoIP90fJWEs3wEjgb/oRz9jtgRl/2w HvHLPsDksL6fwiRI3Xtdco4IFtqa1zS0s4smY4+KNxJwp56DELnelXUWybzuTLUYsZ FFuip+7O5sjvM5622Ye+qQPLIB7jFJU1sQKZGvQYw76pRWPes7anvjW79B/y1O6tmM gPoVL9e++mr6g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 1A20440E6D; Sun, 20 Sep 2026 14:55:44 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id E25F237A for ; Sun, 20 Sep 2026 14:55:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C78FF8101D for ; Sun, 20 Sep 2026 14:55:41 +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 pe70ALF-qWAE for ; Sun, 20 Sep 2026 14:55:40 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp1.osuosl.org 43EB680F9F 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=1789916140; b=Oonh1VDjQuiT2mM6MV7qkomwuVxzBQjZDd314tW8nbB39i8Q+Gpv4dFFNl1PNQU6zDEz 6cYQ9I9KXnypUOYFZSGwkeaaJrvZfnoYO1nDvYcSRTPHSiiyP1FZas2vEhHEa/shFG4MC OjMiThP39D5ByGo0vBnSSZmkxvvzSuCO8EvHwNb07Dc3VRXvTesNrYzxDOOCq1tyH1VjW ePzvGT//vAwtQSYL+FFFxTSRpj+iTO/Z51yke/D8LuSD1nikQ8VYaqpwe5XrCS2PIjx1q PMFsgMJlKRJtiVxCUKRrPie04OxIJSL05j5gTo8vFw/woWbrduxnyK8w/I/mBm4RdGw== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1789916140; h=Received-SPF:DKIM-Signature:X-KAS-Sym:Received:Received:From:To: 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=P2KSOVHGv2SXYo3EDvBo0+AN8dCMAWB/ZKI2obHeL7AXsTP0ZqEWFJlKbJFVE2K1P/TA 6vrQLubOt0fdJobAHEhS5jN9onwpZqHM09DdM2OqPi/pkoGC1Krp7Lpuf0QEchCNrmN+U JRCCq9+6gaHpC5+vav8XtUKf38x+BSB1lGf/S7j48c+6cidIZyU5PKJzsSV4VRAR6q7Qf 4K7HY0NcJ6YV84gPigsVPpJOyzFOYEJKwUpJoouxAkKcixHhoMVucpTnvSx3Aly2JqNSl fhllKtwhZwGM0guYQvHyYAoJ24vuZ4vSKhjeDul+C8r2UUazPx0JnmGtTJCe3Krd4Sw== 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=BGCCKwWF; 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=BGCCKwWF Received: from dd20012.kasserver.com (dd20012.kasserver.com [85.13.140.57]) by smtp1.osuosl.org (Postfix) with ESMTPS id 43EB680F9F for ; Sun, 20 Sep 2026 14:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kuhls.net; s=kas202605290044; t=1789915505; bh=0UNFLQmWWaDo+6KsJ5KF7DS7cJA+hqLv/9gCwAg2G/A=; h=From:To:Subject:Date:In-Reply-To:From; b=BGCCKwWFfQDl4vK5QWKia0KvM2Rcq/euA+wyCzawoFim5p3Ii59rbvzvEKiMBbc/z MqDBUurP/Hdby/JKkk5j+uiRVU7rO1s4Vvw7LdRU19v7JR5LyNdBdWlng/7VGC5lTk InKdDCszlcikXpgRTgFJJNhMStCgaT/3NWT9lZRByT6/5LgLnz80zIxPXi0Y30iPfB w7jbaBg4qdil5n4bE4Y41pRKQ3+lDkMsVkbaEIuDjJNF52OY7orwpQkaZ+wn3kJ9Jt mSErxsw7C6Oj1Jpxv53ZNriUBhuGRxef7kV3Wvohb8uLyhgBZ4Mtfxcte5olKRgW80 bkG3batjhDAvg== X-KAS-Sym: v3:f51bdf72230551df:f9NnCreHs9kSnbMHh6AQdUFyi4vT0ysTuSfFuAQb1+Gxoi8Jfz3lO+KrB2DeTBKeXjT0lwPd2ophCA3F+v+GZvhFlIBU+QKhu+ybVOfg3EHT3MlcRpRvQktOsgJhRsIPALxvYyBhhxNnYCE6obl1o50gAonnv157yLjz1DqCWN47h7t3uGG6haE/+QCl6peUI/vdtKUEOPguOHtIjeLQw2ZSvs9SigPQ0ly22rWdnqQfFx4YWvu/1HbcD6LUsBe0xcLvKWC7ZgeG69JhrpeXORhdzb1VUBZOYiQJc18uAWs2B+mptoIqbEFj6Yl1D0sZ4aKGuMvi+V1/RbjqRW8wdA==:/s9I45m/pf4glKPOAZk4tU5XGKuRwcXHaSEkWX6m79BBPlon7JGMFn9On8JeYLgdRJ/LFSqH0BLqKot3Mc0Ycz3joc7skTITd7oIQueZLwtfExze1e3Q15VScvULz649COvUESAFvxqbRvq5Pwnbyti6kPO/lM3YbXgeVJmMnaoVxUXoEUpTKV+CS2nMvL/XLHoJR1Vy3ZOeshjHeeOP5ryOjita8tZDaWNs4epLEjHvon63CkOrwS1zzIH5MzZJxBvSNtyzcpdtnUEzBlWLHITFHeKugWjS77qkGRPHg5S30kOcSS2GUME6KIe7rfuz25gGtELTnAauPThuav8aowPLl2mWUfsQ3MOAuvgHBaOmtRw5cB2hDxR0PtcKgELgP4dUAYmt4LTsVFVRJrdnmVuE4hxvCfNMn+N3qEoood5aBngGxnGECfNMgotJEOww6Vc03wTQ1bElQ4vYTjTowWXjR2abPYCbUPMYZUhSXAEft7m3M4T4Jdoh44cGaIoolCcsCrfj25RnAsVyZ9ATzckI468DBXefAz+s+pUuWFvXbDKjHuBHnFuIZj8mEos10i0nrpndFMr/ICDsrbdHqyuyO32SkwrzFifwUxBxLwf8sg JOZwgKyjTXd6PeWraX9U8BGCAI0xoXx6Z3BW89tYBD5R+j//NmVjez8FR9HBrs+U3I8cg= Received: from fli4l.lan.fli4l (p54a1b276.dip0.t-ipconnect.de [84.161.178.118]) by dd20012.kasserver.com (Postfix) with ESMTPSA id 7FCACA4C48AB for ; Sun, 20 Sep 2026 16:45:05 +0200 (CEST) Received: from bruckner.lan.fli4l ([192.168.1.1]:47000) by fli4l.lan.fli4l with esmtp (Exim 4.100.1) (envelope-from ) id 1x8Imm-000000000hB-3tBn for buildroot@buildroot.org; Sun, 20 Sep 2026 14:44:57 +0000 From: Bernd Kuhls To: buildroot@buildroot.org Date: Sun, 20 Sep 2026 16:44:17 +0200 Message-ID: <20260920144428.3009612-57-bernd@kuhls.net> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260920144428.3009612-1-bernd@kuhls.net> References: <20260920144428.3009612-1-bernd@kuhls.net> MIME-Version: 1.0 X-Spamd-Bar: -- Subject: [Buildroot] [PATCH v4 56/66] 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: , 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