Hi All,
I have SSL cert monitor through windows script monitor and information given by the script is not correct as per desired result it reflect the cert expired in 20 days but actually the cert will expire after 4 months
there is debug result for polling information through windows script Please help on the same where would be the issue. Thanks in advance
2018-05-21 11:32:04,469 [STP SmartThreadPool Thread #22] [C(null)] DEBUG SolarWinds.APM.Probes.ApplicationJob - Current process: SWJobEngineWorker2 (PID 30140), job execution mode: Poller
2018-05-21 11:32:04,469 [STP SmartThreadPool Thread #22] [C(null)] DEBUG SolarWinds.APM.Probes.ApplicationJobBase - [x103] Creating thread pool. Min: 1 Max:2
2018-05-21 11:32:04,469 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.ProbeExecutors.RegularBatchExecutor - [x103] Component 60962 starting (WindowsScriptProbe) - Regular
2018-05-21 11:32:04,469 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.ProbeExecutors.RegularBatchExecutor - Component probe starting: JobContext - NodeId: 2408, NodeName: sov.hix.edifecs.com, ApplicationId: 3309, ApplicationName: SSL Cert Exp - SSL Auth (3rd Party), ComponentId: 60962, ComponentName: SSL Expiration, CustomLogEnabled: True
2018-05-21 11:32:04,469 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.ProbeBase`1 - Remaining Time: 1191 sec.
2018-05-21 11:32:04,515 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Parsed arguments string: 12.129.20.56:443
2018-05-21 11:32:04,515 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Starting script: cscript.exe //E:vbscript //T:1186 //nologo "C:\ProgramData\SolarWinds\Orion\temp\6c7afbd4-1a00-49cc-9993-a84cf40607cd" 12.129.20.56:443
2018-05-21 11:32:04,515 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Script started [PID:24476]: cscript.exe //E:vbscript //T:1186 //nologo "C:\ProgramData\SolarWinds\Orion\temp\6c7afbd4-1a00-49cc-9993-a84cf40607cd" 12.129.20.56:443
2018-05-21 11:32:04,749 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Trying to get stdout
2018-05-21 11:32:04,765 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Trying to get exit code
2018-05-21 11:32:04,765 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Script returned exit code: 0
2018-05-21 11:32:04,765 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Checking if script exited
2018-05-21 11:32:04,765 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe - Adding results to the result writer.
2018-05-21 11:32:04,765 [STP Pool:103 Thread #0] [C60962] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe -
Begin WindowsScript Execute Result: =============================
Target: 12.129.20.56
Engine: vbscript
Script: ====================================================
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
Dim char
Dim XString
Const ForReading = 1
CertFilePath = "C:\Temp\TMP\cert99.txt"
PluginPath = "C:\OpenSSL-Win64\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 a text file
Do Until oExec.StdOut.AtEndOfStream
char = oExec.StdOut.Read(1)
tstream.Write (char)
If Len(XString) < 20 Then
XString = XString & char
ElseIf XString = "END CERTIFICATE-----" Then
Exit Do
Else
XString = Mid(XString, 2, 19)
XString = XString & char
End If
Loop
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 expiration 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 until expiration
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 converts the date into the 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)
If UBound(Components) = 5 Then
Day = Components(2)
Year = Components(4)
Else
Day = Components(1)
Year = Components(3)
End If
ConvertDate = CDate(Day & "/" & Month & "/" & Year)
End Function
Output: ====================================================
Statistic: 20
Message: Number of days remaning of expiry for SSL certificate are 20
Errors: ====================================================
Result: ====================================================