]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
vpnmain.cgi: Fixes bug13737 - revoke any deleted client certificate
authorAdolf Belka <adolf.belka@ipfire.org>
Tue, 1 Apr 2025 18:07:58 +0000 (20:07 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Apr 2025 09:57:08 +0000 (09:57 +0000)
- 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>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/vpnmain.cgi

index 85119a81d6b7050fe57b52ca8f04fa84d3ac7e68..1c9f9243bf015a51b063203415d67a175e2d07d8 100644 (file)
@@ -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
 ###