openvpn-ui icon indicating copy to clipboard operation
openvpn-ui copied to clipboard

Deleting a revoked client brings to the 404 page

Open zawyelwin opened this issue 1 year ago • 5 comments

When attempting to delete a revoked client, the action redirects to a 404 error page. The deletion process works perfectly if the client is deleted immediately after revocation. However, if the page is refreshed before attempting to delete the client, it results in a 404 error page.

zawyelwin avatar Jun 10 '24 09:06 zawyelwin

Hi @zawyelwin, thanks for the reporting.

Let me test it, looks like a bug.

EDIT: Did you tried to delete certs created with UI or it were old certificates?

I tried to test it with 0.9.5.4 and 0.5.4 openvpn-server container it seems works fine now, but my test is not completed yet. have few reworked certs which will try to delete tomorrow.

d3vilh avatar Jun 16 '24 17:06 d3vilh

I tried to delete the certs created from UI. I am also using the same versions as yours. BTW setup using this https://github.com/d3vilh/openvpn-aws.

Thanks for looking into it.

zawyelwin avatar Jun 18 '24 19:06 zawyelwin

I am having the same problem and I am not running openvpn-aws. It seems like the UI got stuck thinking that there is a cert to be deleted, when you try to delete it (press the delete button) it redirects you to the 404 page.

GoranTopic avatar Jun 25 '24 16:06 GoranTopic

The issue likely occurred in this section

// @router /certificates/burn/:key/:serial/:tfaname [get]
func (c *CertificatesController) Burn() {
	c.TplName = "certificates.html"
	flash := web.NewFlash()
	CN := c.GetString(":key")
	serial := c.GetString(":serial")
	tfaname := c.GetString(":tfaname")
	logs.Info("Controller: Burning certificate with parameters: CN=%s, serial=%s, tfaname=%s", CN, serial, tfaname)
	if err := lib.BurnCertificate(CN, serial, tfaname); err != nil {
		logs.Error(err)
		//flash.Error(err.Error())
		//flash.Store(&c.Controller)
	} else {
		flash.Success("Success! Certificate for the name \"" + CN + "\" and serial  \"" + serial + "\"  has been removed")
		flash.Store(&c.Controller)
	}
	c.showCerts()
}

The Delete (Burn) function expects three parameters (dynamic variables) from the router annotation:

CN Name (Common Name) Serial TFAname (ex : [email protected])

In my case, a 404 page was returned because the TFAname parameter was missing. Therefore, you can remove certificates using the curl command with the appropriate parameters using the following URL structure:

/host/certificates/burn/CNname/Serial/TFAname

For example

# Replace with actual values curl "https://yourdomain.com/certificates/burn/john.doe/ABC123/[email protected]"

Thanks! I hope this helps!

Leeeuijooo avatar Oct 28 '24 04:10 Leeeuijooo

Burn should work fine without TFAname. let me try to reproduce it now. So I created new cert (revoking) and revoked it in a minute: image

2024/12/27 20:54:46.617 [I] [certificates.go:142]  Controller: Creating certificate with parameters: Name=revoking, Staticip=10.0.0.1, Passphrase=, ExpireDays=888, [email protected], Country=CY, Province=PF, City="Paphos", Org="Evacuation", OrgUnit="MyOrganizationalUnit", TFAName=, TFAIssuer=
2024/12/27 20:54:46.617 [I] [certificates.go:119]  Lib: Creating certificate with parameters: name=revoking, staticip=10.0.0.1, passphrase=, expiredays=888, [email protected], country=CY, province=PF, city="Paphos", org="Evacuation", orgunit="MyOrganizationalUnit", tfaname=, tfaissuer=
2024/12/27 20:54:46.617 [D] [utils.go:51]

Then I'll close tab and load it again in incognito mode, after UI container restart and 10 minutes of chill with cup of chai. Then I'll try to remove.

UPDATE:

So, what I did is even better -

I opened session in new browser (Firefox. Previously I used Safari) and delete this revoked certificate without any issue:

image
2024/12/27 21:10:00.510 [I] [certificates.go:192]  Controller: Burning certificate with parameters: CN=revoking, serial=76C27313280F651132AAC620136D8641, tfaname=none
2024/12/27 21:10:00.510 [I] [certificates.go:281]  Lib: Burning certificate with parameters: CN=revoking, serial=76C27313280F651132AAC620136D8641, tfaname=none

I test it in new UI version - 0.9.5.6rc, but in current 0.9.5.5 this works exactly the same.

All the cert details are reading by lib function ReadCerts from the index.txt file.

If the index file not touched - then we should be good.

d3vilh avatar Dec 27 '24 21:12 d3vilh