From: Adolf Belka <adolf.belka@ipfire.org>
To: development@lists.ipfire.org
Cc: Adolf Belka <adolf.belka@ipfire.org>
Subject: [PATCH 2/6] vpnmain.cgi: Fixes bug13737 - revoke any deleted client certificate
Date: Tue, 1 Apr 2025 20:07:58 +0200 [thread overview]
Message-ID: <20250401180802.19784-2-adolf.belka@ipfire.org> (raw)
In-Reply-To: <20250401180802.19784-1-adolf.belka@ipfire.org>
- As the serial number is incremented now for each new cert that is created, then when a
client cert is deleted from the ipsec list in the wui then that cert must be revoked
otherwise it will still be listed in the .index file as a valid certificate and then
the certificate name and DN could never be used again.
- Running the revoke command when deleting a client cert leaves the details in the .index
file but the same name can then be re-used and will get a new serial number etc.
Fixes: bug13737
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
html/cgi-bin/vpnmain.cgi | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi
index 85119a81d..1c9f9243b 100644
--- a/html/cgi-bin/vpnmain.cgi
+++ b/html/cgi-bin/vpnmain.cgi
@@ -1595,17 +1595,25 @@ END
&General::readhash("${General::swroot}/vpn/settings", \%vpnsettings);
&General::readhasharray("${General::swroot}/vpn/config", \%confighash);
- if ($confighash{$cgiparams{'KEY'}}) {
- unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1]cert.pem");
- unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1].p12");
- delete $confighash{$cgiparams{'KEY'}};
- &General::writehasharray("${General::swroot}/vpn/config", \%confighash);
- &writeipsecfiles();
- &General::system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
- } else {
- $errormessage = $Lang::tr{'invalid key'};
- }
- &General::firewall_reload();
+ if ($confighash{$cgiparams{'KEY'}}) {
+ # Revoke the removed certificate
+ if (!$errormessage) {
+ &General::log("charon", "Revoking the removed client cert...");
+ my $opt = " ca -revoke ${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1]cert.pem";
+ $errormessage = &callssl($opt);
+ unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1]cert.pem");
+ unlink ("${General::swroot}/certs/$confighash{$cgiparams{'KEY'}}[1].p12");
+ delete $confighash{$cgiparams{'KEY'}};
+ &General::writehasharray("${General::swroot}/vpn/config", \%confighash);
+ &writeipsecfiles();
+ &General::system('/usr/local/bin/ipsecctrl', 'D', $cgiparams{'KEY'}) if (&vpnenabled);
+ } else {
+ goto VPNCONF_ERROR;
+ }
+ } else {
+ $errormessage = $Lang::tr{'invalid key'};
+ }
+ &General::firewall_reload();
###
### Choose between adding a host-net or net-net connection
###
--
2.49.0
next prev parent reply other threads:[~2025-04-01 18:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 18:07 [PATCH 1/6] vpnmain.cgi: Fixes bug13737 - remove unneeded &cleanssldatabase calls Adolf Belka
2025-04-01 18:07 ` Adolf Belka [this message]
2025-04-02 10:21 ` [PATCH 2/6] vpnmain.cgi: Fixes bug13737 - revoke any deleted client certificate Michael Tremer
2025-04-02 10:41 ` Adolf Belka
2025-04-02 13:52 ` Michael Tremer
2025-04-01 18:07 ` [PATCH 3/6] include: Add the contents of the ipsec certs directory to the backup Adolf Belka
2025-04-01 18:08 ` [PATCH 4/6] backup.pl: Fixes bug13737 - restarts ipsec to use the restored certs etc Adolf Belka
[not found] ` <F37E461A-91BF-45B6-904E-92E85B51DE2C@rymes.net>
2025-04-01 20:44 ` Adolf Belka
2025-04-01 21:46 ` Adolf Belka
2025-04-01 21:55 ` Tom Rymes
2025-04-01 21:52 ` Tom Rymes
2025-04-02 10:24 ` Adolf Belka
2025-04-02 10:25 ` Michael Tremer
2025-04-01 18:08 ` [PATCH 5/6] core194: Ship the vpnmain.cgi changes Adolf Belka
2025-04-01 18:08 ` [PATCH 6/6] core194: Ship the backup file changes Adolf Belka
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=20250401180802.19784-2-adolf.belka@ipfire.org \
--to=adolf.belka@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