问题
When I use Octave 3.8.1 installed in Cygwin, I can successfully download https pages like this:
urlwrite('https://www.google.com', 'downloaded.html')
However, when I use Octave 3.6.4 installed in Windows 7 SP1 Pro 64bit, urlwrite() doesn't work:
octave-3.6.4.exe:18> urlwrite('https://www.google.com', 'downloaded.html')
error: urlwrite: curl: Problem with the SSL CA cert (path? access rights?)
urlread() has the same problem. Is there a good way to avoid this error?
Update:
Following Andy's advice, I tried to fix a curl-related problem. At the moment, curl.exe can work for https, but libcurl (I think embedded in octave) doesn't work for https. let me explain what I did.
I downloaded curl.exe from here. At first, it doesn't work for https like this:
C:\somewhere\curl-7.33.0-win64-nossl>curl https://www.google.com/
curl: (1) Protocol https not supported or disabled in libcurl
After I downloaded "cacert.pem" from here, renamed it to "curl-ca-bundle.crt", and put it in C:\windows\system32, curl.exe can extract pages from https sites.
However, when I use urlwrite() in Octave, it's still not working. I guess that octave internally calls libcurl API, but I don't know how to force libcurl to find CA certs.
回答1:
I have the same probem using urlread() in Octave 4.0.0 for Windows. I tried a few things but none worked. I did manage to get the curl command line tool to work tho. So in the end the easiest thing for me was to write my own urlread() which called curl using Octave's system() function:
function retval=my_urlread(url)
command=['curl --silent ','"',url,'"'];
[output,text]=system(command);
retval=text;
endfunction
回答2:
I analyzed source code of CURL and can say: you can't solve this without source editing. CURL has two entrance points: if you run curl.exe it setup libcurl with environment variables and files from working dir, and if you're using libcurl through curl_easy_perform from libcurl.dll (like Octave), you must provide all settings manually. So you can setup your environment such way, that curl.exe from Octave's binary dir will load data without additional parameters (curl.exe https://google.com)
, but Octave's urlread
will not work.
来源:https://stackoverflow.com/questions/26237960/urlread-urlwrite-dont-work-for-https-pages-in-octave-for-windows