4
$\begingroup$

It seems that with Mathematica 8 and 9 it is not possible anymore to download files from SSL encrypted urls. In my case (Fedora 30) on Mathematica 8 (it has no URLSave yet) I get

<< Utilities`URLTools`
FetchURL["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master"]
FetchURL::conopen: The connection to URL https://codeload.github.com/WolframResearch/WolframLanguageForJupyter/zip/master cannot be opened. If the URL is correct, you might need to configure your firewall program, or you might need to set a proxy in the Internet connectivity tab of the Preferences dialog (or by calling SetInternetProxy).  For HTTPS connections, you might need to inspect the authenticity of the server's SSL certificate and choose to accept it.

While on Mathematica 9 evaluating

URLSave["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master", CreateTemporary[]]

generates

During evaluation of In[15]:= URLSave::invhttp: SSL connect error. >>

Out[15]= $Failed

I wonder if there are any workarounds available since WRI is obviously not going to provide any patches for such old Mathematica versions. I also asked a similar question regarding Mathematica 10 here.

$\endgroup$
  • 4
    $\begingroup$ For V8, you can try a different version of Java, something like ReinstallJava[CommandLine -> "/usr/bin/java"] and then try FetchURL again. V9 is trickier, the best I could think of right now is replace libcurl.so with a newer one (could be done via LD_PRELOAD too) and add "VerifyPeer" -> False. $\endgroup$ – ilian Jan 8 at 2:26
  • $\begingroup$ Many thanks! Both tricks work, although I'm a bit unsure if they are simple enough for an average user to install FeynCalc via install.m from GitHub. But in any case these are valid workarounds that should help other Linux users facing similar problems. If you like, you can turn your comment into an answer that I would accept. I could also do it if you have no time for that. The main point is that someone googling for this issue should find this question straight away. $\endgroup$ – vsht Jan 8 at 9:24
  • $\begingroup$ It's totally fine if you want to make this into an answer. I believe the Java workaround is quite reasonable, unlike the other one. I'll post an update in case I can come up with a less heavy-handed way to handle the V9 problem. $\endgroup$ – ilian Jan 8 at 23:07
  • $\begingroup$ Done. Thanks again for your help. $\endgroup$ – vsht Jan 9 at 13:30
  • $\begingroup$ @ilian Seems that not only Linux is affected but also Windows 10 and Mac OS. Is there something like LD_PRELOAD-trick one could use on Windows 10 for Mathematica 9? $\endgroup$ – vsht Jan 12 at 1:08
2
$\begingroup$

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    
|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ Thanks so much for fixing Mma 9! $\endgroup$ – vsht Jan 29 at 22:13
5
$\begingroup$

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[]]
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.