This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

ConvertDate Function returns incorrect date

I wasn't really sure where the best place to put this was I figure since it's a script question I'd put it here, even though it's a script for a SAM monitor.

What I'm using is this.-> SolarWinds Knowledge Base :: How to monitor your SSL certificate expiration date.
I have it setup as a Windows Script Monitor in SAM 6.1.

I noticed, thankfully early enough, that the function at the end of the script ConvertDate() returns an incorrect date for some of my certs. I'm monitoring 38 SSL certs and 13 of them return incorrect values where it's swapping the month and the date while getting converted..

I modified the output for troubleshooting to echo the variables in the calculation and this is what I get

The variable "Expiry" returns a value of May 1 20:55:32 2015 GMT, which is correct

The variable "ExpDate" returns 1/5/2015, which is obviously not the same as above

It then calculates the DaysLeft variable, but since ExpDate is incorrect, I get the wrong results.

The issue, to me, seems to lay squarely in the ConvertDate function as the rest of the script works and is working great for my 25 other domains I'm monitoring. But I can't for the life of me figure out why.

a handful of the domains it's not working for are: (remove the undercores, I don't want these sites to be searchable here):

www.sellc_ashad_vances.com - Expiry=May 1 20:55:32 2015 GMT, ExpDate=1/5/2015

webmail.naba_ncard.com - Expiry=Jan 11 23:02:36 2015 GMT, ExpDate=11/1/2015

myres_ourceportal.com - Expiry=Jan 3 14:12:55 2015 GMT,  ExpDate=3/1/2015

Any help is appreciated.

  • For a start, what SAM version are you using?  SSL monitoring was bundled with SAM starting 4.2.  Whatever bug exists in the script may have been fixed/resolved by now.  It also works without the need for the OpenSSL binaries.

    Taking a quick look at the script, CDate is being passed the format day/month/year, so what you are getting back is exactly what's being put in.  Assuming you're on a US computer/server, you can simply swap the variables around so the new line will look like this:

    ConvertDate = CDate(Month & "/" & Day & "/" Year)

    This seems to work in a handful of test cases, for example:

    - "Dec  9 20:55:32 2015 GMT"

    - "Dec 25 20:55:32 2015 GMT"

    - "May  5 20:55:32 2015 GMT"

    - "Jan 11 20:55:32 2015 GMT"

    - "Jan  3 20:55:32 2015 GMT"

  • The template included with Solarwinds only accounts for 1 SSL certificate per node, I have in some cases several on one server, so that didn't cut it for me.

    As for my issue, the converting only went wrong when the dates were passed from the openssl parts parsing to get the date. I really don't have a solid answer as to why it's not working for me, however I did fix it in that I modified the script for the ones which were not working.
    Basically for the ones NOT working properly I changed this part from the script from

    Original:

    Day = Components(1)
    Year = Components(3)

    If UBound(Components) = 5 Then

    Day = Components(1)
    Year = Components(3)

    Else

    Day = Components(1)
    Year = Components(3)

    End If

    To this:

    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

    Not really sure the reason as to why but I went through each of my certs and counted the day's manually to verify this is correct and it does correct the ones which were previously showing up as incorrect using the original script.

    It's strange but I'm good for now. Thank you for looking into this. Jonathan Angliss