Re: Access to x509 certificate using LWP?
[email protected] (Philip Kizer) Thu, 28 Feb 2013 09:43:20 -0600
| Newsgroups | perl.libwww |
|---|---|
| Message-ID | <[email protected]> |
On 2013, Feb 27, at 10:37, Sebastien Koechlin <[email protected]> = wrote: > I'm using a Perl script to monitor many webservers. I do a request on = a page > using LWP, check header and content, and print the result = (OK/WARNING/ERROR). >=20 > For https; I would like to also check the certificat expiration date = and > report a WARNING if the expiration date is in few weeks. >=20 > Is there any way to access the certificat sent by the remote server = using LWP? >=20 > (I'm using Red Hat EL 5.3 / perl-libwww-perl-5.805) I see there have been several non-LWP suggestions, and unfortunately = this is another. But, what you describe sounds extremely similar to = what Nagios and its checks do so I'll just mention that I use the = as-shipped check_http module to do that as follows: define command { command_name check_https_cert command_line $USER1$/check_http -S -C 30 -H $HOSTADDRESS$ = $ARG1$ $ARG2$ $ARG3$ } And then in a service definition I use one of (obviously altering the = www.example.com to the hostname of the virtual server I'm interested in = if a host serves for multiple names): check_command check_https_cert check_command = check_https_cert!-H!www.example.com Sorry it's not a pure perl solution, but it does address your ultimate = need even though it's not exactly how you were asking for it to be done. You can find it as part of the normal plugin package at: http://nagiosplugins.org/ or your favorite OS package manager. -p