OPNsense Forum

English Forums => General Discussion => Topic started by: gaetanlord on September 12, 2022, 10:36:27 PM

Title: get webpage content from the command line
Post by: gaetanlord on September 12, 2022, 10:36:27 PM
Hi

Trying to find a way to get the content of the certificate list  webpage  (system_certmanager.php )

I haven't found any way to find the certificate expiration date from the API and from the XML backup

We issue short expiration dates on our VPN certificate, and I'm looking at a way to find the one close to expiration. I'd like to fetch the page and parse the date. Any idea how to proceed, I'm open to any solution

Regards
Title: Re: get webpage content from the command line
Post by: MrB on September 14, 2022, 10:51:07 PM
Reading it from the backup file should be pretty easy if the data is stored there. Below an example of how to read the expiration date for the self-signed web cert from the backup xml-file. This uses xmllint to parse the xml-file, decodes the <crt> node and passes the result to openssl x509 to display the data

xmllint --xpath '/opnsense/cert/crt/text()' config-file.xml | base64 -d | openssl x509 -noout -subject -enddate

Don't have any VPN certificates stored on my own setup, so adjust the xpath for the correct node, and of course the name of the input file.