43

I have the following code in my coldfusion code that works:

<cfexecute name="curl" arguments = "https://myPath/myFile.xlsx -k" timeout="10" variable="test" />
<cfdump var="#test#" />

This downloads an Excel file from the specified path using cURL and dumps it to the browser, which works fine.

However, I can't get the same thing to work with Wget.

First I tried:

<cfexecute name="wget" arguments = "https://myPath/myFile.xlsx" timeout="10" variable="test" />
<cfdump var="#test#" />

This returns an empty string. It seems we need to use the equivalent of cURL's "-k" for Wget, to tell it to ignore SSL certificate errors. So I tried:

<cfexecute name="wget" arguments = "--no-check-certificate https://myPath/myFile.xlsx" timeout="10" variable="test" />
<cfdump var="#test#" />

This gives me the following results:

Usage: wget [OPTION]... [URL]... Try `wget --help' for more options. 

How can I use Wget within cfexecute to download the excel file, ignoring SSL certificate errors?

EDIT:

Running wget --no-check-certificate "https://myPath/myFile.xlsx" directly from the command line works.

froadie
  • 79,995
  • 75
  • 166
  • 235
  • If that runs from the command line that would seem to rule out my idea that wget isn't compiled with SSL support. I notice you how quotes around the URL in the command line example you give. Does it work without those? I expect it would but they are the one difference I can see between that and the cfexecute. – Andrew Myers Oct 03 '14 at 11:26
  • 1
    Another possibility - are you sure that the command line and CF are using the same version of wget? Perhaps put the full path to the executable in CF as a double check? – Andrew Myers Oct 03 '14 at 11:57
  • How about paths? Does CF really know where to get wget? Please try launching wget in CF using explicit complete path to your wget instance. – Konstantin Jul 04 '15 at 16:02

2 Answers2

52

Please use the wget with --no-check-certificate e.g.

wget --no-check-certificate "https://myPath/myFile.xlsx"

should work.

Moshe
  • 4,635
  • 6
  • 32
  • 57
vaibhav singhal
  • 883
  • 8
  • 9
3

From the wget man page (http://linux.die.net/man/1/wget)

" HTTPS ( SSL/TLS ) Options

To support encrypted HTTP ( HTTPS ) downloads, Wget must be compiled with an external SSL library, currently OpenSSL. If Wget is compiled without SSL support, none of these options are available."

You might need to check whether the version of wget you are using supports SSL.

Could cfhttp do what you need though?

https://wikidocs.adobe.com/wiki/display/coldfusionen/cfhttp

If you're using a self signed certificate you can add it to your JVM's key store to avoid the certificate errors.

Andrew Myers
  • 650
  • 5
  • 9