I imported a template from thwack and i'm attempting to use it to monitor expiration date for SSL certificates. The script that runs looks good except for the value(statistic returned) isn't correct. It looks like the date format its using is in the U.K format and I'm in the U.S. Please see below for the script thats running
*******************************************************************************************************************************************
'///////////////This script calculate the no of days remaining for expiry of SSLcertificate////////////////////////////
'Before using this script you need to install OPENSSl pluging which is freely available on internet////////
'Make sure the path given below should have the pluging installed on or change the path as per your OpenSSL plugin
'installation
'you need to pass the argument site name plus port number for example
'www.google.co.uk:443
'**************************************************
Option Explicit
Dim oShell
Dim ArgObj
Dim Fh
Dim FSO
Dim Line
Dim Expiry
Dim DaysLeft
Dim ExpDate
Dim oExec
DIm cert
DIm tstream
dim i
dim str
Dim PluginPath
Dim CertFilePath
Const ForReading = 1
CertFilePath = "C:\TMP\cert.txt"
PluginPath = "C:\Program Files\Solarwinds\Common\OpenSSL\bin\"
Set FSO = CreateObject("Scripting.FileSystemObject")
set tstream = fso.createtextfile(CertFilePath,true)
ArgObj = wScript.Arguments(0)
Set oShell = WScript.CreateObject ("WScript.Shell")
''/////////Calling funtion to retieve the host
set oExec=oShell.exec ( pluginpath & "openssl.exe s_client -connect " & ArgObj )
'/////////////write the certificate into text file ///////
for i=1 to 3000
tstream.write oExec.StdOut.Read(1)
next
tstream.close
oExec.Terminate
'/////////////////Read SSL certificate for start date and end date
set oExec=oShell.exec ( pluginpath & "openssl.exe x509 -noout -in " & CertFilePath & " -dates")
'///////Return start date and end date of the certificate///////
line = oExec.StdOut.Readall
'//////////////////////get the expiry date of the certificate
expiry = (mid(line,len(line)-24,24))
ExpDate=ConvertDate(expiry)
'/////// Calculating number of days
DaysLeft = DateDiff("d",now(),ExpDate)
'/////////////Display the number of days remaining for expiry
wscript.echo "Statistic: " & DaysLeft
wscript.echo "Message: Number of days remaning of expiry for SSL certificate are " & DaysLeft
'///////object Closing code //////////////
oExec.Terminate
Set oShell=Nothing
set oExec=Nothing
'/////////////////This function convert the date into required format///////////////////
Function ConvertDate (DateStr)
Dim Components
Dim Month
Dim Day
Dim Year
Components=Split(DateStr)
Select Case Components(0)
case "Jan","January"
Month=1
case "Feb","February"
Month=2
case "Mar","March"
Month=3
case "Apr","April"
Month=4
case "May"
Month=5
Case "Jun","June"
Month=6
case "Jul","July"
Month=7
case "Aug","August"
Month=8
case "Sep","Sept","September"
Month=9
case "Oct","October"
Month=10
case "Nov","November"
Month=11
case "Dec","December"
Month=12
case else
Month=1
End Select
Day=Components(1)
Year=Components(3)
ConvertDate=CDate(Day&"/"&Month&"/"&Year)
End Function
*****************************************************************************************************************************************