From patchwork Thu Feb 5 18:51:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 9482 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "R12" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4f6RGH2p1tz3wjn for ; Thu, 05 Feb 2026 18:54:15 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [IPv6:2001:678:b28::201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (Client CN "mail02.haj.ipfire.org", Issuer "E8" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4f6RGG4lCJz5Z9 for ; Thu, 05 Feb 2026 18:54:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [IPv6:::1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4f6RGB6Gvjz3399 for ; Thu, 05 Feb 2026 18:54:10 +0000 (UTC) X-Original-To: development@lists.ipfire.org Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "R12" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4f6RG81PFgz2xHh for ; Thu, 05 Feb 2026 18:54:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4f6RG62s7Cz2S; Thu, 05 Feb 2026 18:54:06 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1770317646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QBB+AwQ0Zu54XHsqim7UHBJavvfY10+0QJFOZUL4gws=; b=qg/Aud5FFz5yHFTc35w8KGxEI3nwsImGesjSHIar/PWEXo10wsVXuulAp6c4EqNTfQR/Az JWo9U3+qtLIzo4AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1770317646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QBB+AwQ0Zu54XHsqim7UHBJavvfY10+0QJFOZUL4gws=; b=YtdWfPwBOa0eDWB6c/fq/DfVO8hSfCC6QjqMGTjhUhouWfl6Mq6P3Vyc68fTVaDncKQQ0D 92ZYwPxHRTWAjysquI++JSGvNNXTJ7BvUXeWxzyWF5LRVFTyuM9dlGEYP7hNzptJNt5+Hg jCf1Rdh6V9KJkLLkouMG1KffInvwhKT0ecbv1xm3Prkz4BCURXSJo4+96kDdhFvDCYhtk2 ApktA1hxQJGmgVbMRQdB6BC/NFF0Pk49CP/tS6KX3Gxc7liCqqOYIp1O57PXc0ffGDpaOU ZgOQw1nnZ2b3KfXlpjDEjLd40L8yd8Pd+8+aI43ZBzclGBFhwpeK5Cppajp4/Q== From: Stefan Schantl To: development@lists.ipfire.org Cc: Stefan Schantl Subject: [PATCHv2] ovpnmain.cgi: Re-implement iscertlegacy function Date: Thu, 5 Feb 2026 19:51:34 +0100 Message-ID: <20260205185134.8413-1-stefan.schantl@ipfire.org> Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: MIME-Version: 1.0 Re-implement the iscertlegacy function to proper detect any kind of legacy certificate by using the openssl legacy switch. Fixes #13936 Signed-off-by: Stefan Schantl --- html/cgi-bin/ovpnmain.cgi | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index e53bd6e28..b435d9e1b 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -143,12 +143,32 @@ my $col=""; sub iscertlegacy { my $file=$_[0]; - my @certinfo = &General::system_output("/usr/bin/openssl", "pkcs12", "-info", "-nodes", - "-in", "$file.p12", "-noout", "-passin", "pass:''"); - if (index ($certinfo[0], "MAC: sha1") != -1) { - return 1; - } - return 0; + my @openssl_cmd = ("/usr/bin/openssl", "pkcs12", "-info", "-nodes", + "-in", "$file.p12", "-noout", "-passin", "pass:"); + my $ret; + + # Execute the openssl command. + $ret = &General::safe_system(@openssl_cmd); + + # Early exit if the openssl return code is zero and we do not have a + # lecacy certificate. + return 0 if ($ret eq "0"); + + # In case we got an return code of one, retry with enabled legacy option. + # + # Add option to enable legacy ciphers to the openssl command. + push(@openssl_cmd, "-legacy"); + + # Re-execute the openssl command with legacy option. + $ret = &General::safe_system(@openssl_cmd); + + # Exit and return 1 if the return code of the openssl command is zero + # with enabled legay option, which indicates a legacy certificate. + return 1 if ($ret eq "0"); + + # If we got here, the openssl command was not able to detect + # which kind of certificate is used. + return undef; } sub is_cert_rfc3280_compliant($) {