SSL errors when using URLFetch or URLSave in versions 8 or 9
As explained by ilian in his comment to my question, one can work around these issues in the following way
Mathematica 8
You need to switch to a different version of Java as the one used in Mathematica by default.
Linux
The standard JVM of your Linux system should be fine. On my system (Fedora 30) it is currently OpenJDK 1.8.0
$/usr/bin/java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
So in Mathematica we first need to run the following code
<< JLink`
ReinstallJava[CommandLine -> "/usr/bin/java"]
which (in my case) returns
LinkObject[/usr/bin/java -classpath "/media/Data/Software/Mathematica/8.0/SystemFiles/Links/JLink/JLink.jar" -Xmx256m -Djava.system.class.loader=com.wolfram.jlink.JLinkSystemClassLoader -Djava.util.prefs.PreferencesFactory=com.wolfram.jlink.DisabledPreferencesFactory com.wolfram.jlink.Install -init "/tmp/m00000291671",7,4]
After that
<< Utilities`URLTools`
FetchURL["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master"]
works as expected. Notice that you need to load JLink
and use ReinstallJava
each time you start the kernel and want to use FetchURL
.
Windows 10
You need to install a JVM (I used jre-8u231-windows-x64.exe
from java.com) first. Then execute something like
<< JLink`
ReinstallJava[CommandLine -> "C:\\Program Files\\Java\\jre1.8.0_231\\bin\\java.exe"]
before using FetchURL
. Notice that you might need to adjust the path to java.exe
accordingly
Mathematica 9
Linux
Here you need to do some work already when starting Mathematica and use LD_PRELOAD
to preload libcurl.so
On my system (Fedora 30) I have libcurl.so.4.5.0
installed.
So we run Mathematica as
LD_PRELOAD=/usr/lib64/libcurl.so.4.5.0 mathematica9.0
and
URLSave["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master", CreateTemporary[]]
just works. Setting "VerifyPeer" -> False
as originally suggested by ilian seems unnecessary here, but perhaps it might be needed for other links.
Windows 10
The current workaround (as suggested by ilian) is to use powershell instead of the built-in URLSave
. You can use something like
URLSave2[url_String, file_String]:=
If[ Run["powershell.exe -command iwr -outf " <> file <> " " <> url]===0,
file,
$Failed
]
to get it working as in
URLSave2["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master", CreateTemporary[]]
Just an addendum for Mathematica 9 on Windows and Linux (Mac should already work).
The problem can be resolved by installing an updated version of the HTTPClient
paclet and restarting the kernel, for example
Map[PacletSiteUpdate, PacletSites[]];
PacletUpdate["HTTPClient"]
(* Out[2]= Paclet[HTTPClient, 9.0.1, <>] *)
Quit
Subsequently this should work without any SSL errors
In[1]:= $Version
Out[1]= 9.0 for Linux x86 (64-bit) (February 7, 2013)
In[2]:= URLFetch["https://codeload.github.com", "StatusCode"]
Out[2]= 200