Hi,
where this certificate is located? If it is web site certificate or file on file system you can use openssl command line tool to extract it (and run it as ExternalParameter in NetXMS agent). For example, the following external parameter will extract certificate validity date for given web site:
Requesting it as
HTTPS.CertificateExpireDate(netxms.org)
will return
Sep 2 21:57:24 2018 GMT
Then you can use NXSL transformation script to convert it to UNIX timestamp:
Alternatively you can use
to get number of seconds till certificate expiration.
Best regards,
Victor
where this certificate is located? If it is web site certificate or file on file system you can use openssl command line tool to extract it (and run it as ExternalParameter in NetXMS agent). For example, the following external parameter will extract certificate validity date for given web site:
Code Select
ExternalParameterShellExec = HTTPS.CertificateExpireDate(*):echo | openssl s_client -showcerts -servername netxms.org -connect netxms.org:443 2>/dev/null | openssl x509 -inform pem -noout -enddate | cut -d = -f 2
Requesting it as
HTTPS.CertificateExpireDate(netxms.org)
will return
Sep 2 21:57:24 2018 GMT
Then you can use NXSL transformation script to convert it to UNIX timestamp:
Code Select
if ($1 match "^\\s*([A-Za-z]+)\\s+([0-9]+)\s+([0-9]+):([0-9]+):([0-9]+)\s+([0-9]+)")
{
t = new TIME();
t->year = $6;
t->mon = MonthFromName($1);
t->mday = $2;
t->hour = $3;
t->min = $4;
t->sec = $5;
t->isdst = -1;
return mktime(t);
}
else
{
return 0; // error
}
sub MonthFromName(name)
{
m = 0;
for(n : %("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
{
if (n == name)
return m;
m++;
}
return 0; // error
}
Alternatively you can use
Code Select
return mktime(t) - time();
to get number of seconds till certificate expiration.
Best regards,
Victor