WGet fails with 0x1 code running PHP script under SSL/HTTPS

Scheduled tasks that call a PHP script using Wget.EXE run fine for all sites except those running under SSL on https.

Problem

A Windows 2008 Server R2 server hosting a number of Kayako eSupport and SupportSuite applications uses Task Scheduler to run the mail parser for collecting ticket emails. The task scheduler runs the open source WGet utility to call a PHP script, as below: –

“C:\Program Files (x86)\GnuWin32\bin\wget.exe” -q -O NUL http://www.sampledomain.com/samplefolder/index.php

This worked fine until it was used for a site running entirely on HTTPS. It was clear that the issue was with SSL because the task ran OK when amended to run in HTTP. However this couldn’t be a permanent solution because we use URL rewriting to force all requests to use HTTPS.

Solution

The answer took some finding but was simple to implement. It was to add the –no-check-certificate parameter to the WGet command, as below: –

“C:\Program Files (x86)\GnuWin32\bin\wget.exe” -q -O NUL –no-check-certificate https://www.sampledomain.com/samplefolder/index.php

Full documentation for WGet is here: http://www.gnu.org/software/wget/manual/wget.html