openwisp / openwisp/openwisp-controller

[bug] Deleting CA/Certificate in use by VPN Client corrupts device configuration

Open
#1,419 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
773
Forks
315
Avg merge
2d 16h
Merged PRs (30d)
14

Description

Describe the bug

When a CA or Certificate used by an active VPN Client is deleted from the admin panel, the associated device's configuration becomes corrupted instead of being prevented or properly handled. The configuration status incorrectly remains as "applied" even though the configuration contains unresolved context keys.

Steps To Reproduce

  1. Create a VPN with OpenVPN backend
  2. Create a CA and certificate for the VPN server
  3. Create a VPN Client template for the VPN server created in the previous step
  4. Apply the template to a device and verify that the device's config.status changes to "applied"
  5. Navigate to http://127.0.0.1:8000/admin/pki/cert/
  6. Delete the certificate that was created for the device to be used in OpenVPN configuration
  7. Confirm the deletion in the confirmation dialog

Expected behavior

The system should prevent deletion of CA and Certificate objects when they are actively used in a VPN Client by a device. Instead of allowing deletion, the confirmation page should direct the user to remove the template from the specific device, which will automatically delete the certificate.

Actual behavior

  • The certificate and associated VPN Client are deleted
  • The device's configuration status remains "applied" instead of changing to "modified"
  • Cache invalidation for the Config.checksum is not triggered
  • When previewing the configuration, the context keys for certificate paths and content are not resolved
  • This results in a corrupted configuration with invalid placeholder values

Screenshots

OpenWISP hints that deleting the Cert object will delete the related VpnClient:
VPN deletion confirmation page showing cascading deletes

Corrupted configuration with unresolved context keys:
Corrupted configuration with unresolved context keys

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the admin/pki/cert/confirmation flow and trace how deleting a certificate cascades to the VPN Client and device configuration. Reproduce the OpenVPN setup described in the issue, then verify that deletion is prevented while the certificate is in active use and that removing the template from the device remains the supported cleanup path.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.