From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Cc: Stefan Schantl <stefan.schantl@ipfire.org>
Subject: [PATCHv2] ovpnmain.cgi: Re-implement iscertlegacy function
Date: Thu, 5 Feb 2026 19:51:34 +0100 [thread overview]
Message-ID: <20260205185134.8413-1-stefan.schantl@ipfire.org> (raw)
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 <stefan.schantl@ipfire.org>
---
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($) {
--
2.47.3
reply other threads:[~2026-02-05 18:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260205185134.8413-1-stefan.schantl@ipfire.org \
--to=stefan.schantl@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox