Arduino IDE can't download libraries and Boards

Hello everyone, first of all I'm sorry for my bad english, and second thanks to those who can help me!
Now this is my problem: yesterday i was trying to install the ESP8266 Board on Arduino IDE 1.8.12 but it gave me the error "Error downloading https:/ etc etc" (not so relevant now).
Before that i was able to explore the Boards and Libraries Managers without any problems, but now if I open Boards manager i can see only the first choice (Arduino AVR Boards) and the window gives me this error:

Error downloading https://downloads.arduino.cc/packages/package_index.json
java.lang.RuntimeException: java.lang.Exception: Errore durante lo scaricamento di https://downloads.arduino.cc/packages/package_index.json
 at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onUpdatePressed$1(ContributionManagerUI.java:150)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.Exception: Errore durante lo scaricamento di https://downloads.arduino.cc/packages/package_index.json
 at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:139)
 at cc.arduino.contributions.packages.ContributionInstaller.download(ContributionInstaller.java:333)
 at cc.arduino.contributions.packages.ContributionInstaller.downloadIndexAndSignature(ContributionInstaller.java:307)
 at cc.arduino.contributions.packages.ContributionInstaller.updateIndex(ContributionInstaller.java:285)
 at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onUpdatePressed$1(ContributionManagerUI.java:146)
 ... 1 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
 at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
 at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
 at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
 at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
 at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1639)
 at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
 at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
 at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
 at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
 at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
 at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
 at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162)
 at cc.arduino.utils.network.FileDownloader.downloadFile(FileDownloader.java:181)
 at cc.arduino.utils.network.FileDownloader.download(FileDownloader.java:132)
 at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:137)
 ... 5 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
 at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
 at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
 at sun.security.validator.Validator.validate(Validator.java:262)
 at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
 at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
 at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
 at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1621)
 ... 18 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
 at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
 at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
 at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
 at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
 ... 24 more

A similar thing happens if I open the Libraries manager, there I can't see any libraries and the window gives me this error (i cut che code for exceeded lenght of the post:

Error downloading  https://downloads.arduino.cc/libraries/library_index.json
java.lang.RuntimeException: java.lang.Exception: Error downlaoding https://downloads.arduino.cc/libraries/library_index.json
 at cc.arduino.contributions.libraries.ui.LibraryManagerUI.lambda$onUpdatePressed$2(LibraryManagerUI.java:206)
 at java.lang.Thread.run(Thread.java:748)
.
.
.

I can't figure out why until yesterday I was free to install everything and now I'm completely lost...
I'm using my Win10 64bit work laptop with admin privileges, and the network is controlled by a Symantec business software.
Till now these was my various attempts:
-Delete Arduino15 folder
-Clear reinstall of Arduino 1.8.12
-Clear install of Arduino 1.8.9 (why not :sweat_smile: )
-Reboot the pc
-Connect to another network (3G hotspot)
-Clear Pc files and Register problems with CCleaner
-Enter in CMD the string: "setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true"
-With browser the two links works as well.

A little update: in preferences i've tried to put in Additional Board Manager URLsfield "http://downloads.arduino.cc/packages/package_index.json" (not https) and the board manager now works... but the libraries are still broken

I found this post with a workaround that some people reported to fix this issue:

Open the folder that contains the Arduino IDE installation (default location is C:\Program Files (x86)\Arduino).

Open the file arduino.l4j.ini in a text editor, running it as administrator.

Add the following lines to the file:

-Djavax.net.ssl.trustStore=NUL
-Djavax.net.ssl.trustStoreType=Windows-ROOT

Save the file.

Restart the Arduino IDE.

I don't know whether it will help or not.

4 Likes

Thanks, it really helps me, i've found the same code but without any informations about the file .ini!

Basically the proxy of my corporation block the handshake between Arduino IDE and every https URL during the establishing of a secure connection, editing that file, Arduino trust any connections like valid (even with https).
I hope this post will helps anyone with this problem!

Anyway while i was trying to solve it by myself i found out another solution for manual installation of new boards:
-Install arduino IDE on another PC (possibly with the same OS), that has no problems with corporate proxy
-Install the board (in my case ESP8266)
-copy the folder C:\Program Files (x86)\Arduino\hardware from the non-corporate pc to the corporate one
-copy the folder C:\Users\User Name\AppData\Local\Arduino15 from the non-corporate pc to the corporate one

Obviously the two installations are identical, boards and libraries.

Please correct any mistakes if I wrote something wrong, I'm a noob of these arguments and I never stop learning!

You're welcome. I'm glad to hear it's working now. Thanks for taking the time to post an update with your findings.

cele93:
-copy the folder C:\Program Files (x86)\Arduino\hardware from the non-corporate pc to the corporate one

This step is most likely not necessary, since that folder is only supposed to contain the Arduino AVR Boards platform that comes bundled with the Arduino IDE installation. Some people do manually install boards platforms into that folder, in which case you could copy it over. Boards Manager never touches that folder.

The better place to do manual boards platform installations is {sketchbook folder}/hardware, where {sketchbook folder} is configured in the Arduino IDE's File > Preferences > Sketchbook location option. So if you want to be really complete in transferring every possible platform installation location, you should also do {sketchbook folder}/hardware. If you haven't done any manual installations then that folder won't exist.

cele93:
Please correct any mistakes if I wrote something wrong

It is a good workaround. It's best to get Boards Manager working, since it's a very convenient method for installing and updating boards platforms, but in a locked down network situation, your workaround may be the best option.

It worked like a pro…!!! Thanks for this

Hello!

Beautiful answer and this is worked for me on Windows previously.

But now i'm using Linux Ubuntu 21.04 and can't find appropriate file in untarred arduino folder or anywhere else.

On Linux, Java options are set via the JAVA_TOOL_OPTIONS environment variable. You could also set them in the script that starts the Arduino IDE. This is the file named arduino that is located in the Arduino IDE installation folder. You can open it in a text editor.

Could you elaborate? I'm really noob in these things=)

I found JAVA_TOOL_OPTIONS within described arduino file:

export JAVA_TOOL_OPTIONS=`echo $JAVA_TOOL_OPTIONS | sed 's|-javaagent:/usr/share/java/jayatanaag.jar||g'`

But i don't understand how to insert additional values to this string, and also don't know how to properly convert this line below for Linux OS:

-Djavax.net.ssl.trustStoreType=Windows-ROOT

This line is removing a potentially problematic option. You can certainly add options there, but there really isn't any good reason to do it there.

Looking at the script more closely, I think you would be best to add them here:
https://github.com/arduino/Arduino/blob/1.8.15/build/linux/dist/arduino#L28

JAVA_OPTIONS=("-DAPP_DIR=$APPDIR")

This is a Bash-style space separated list. So if you wanted to add the option -Djavax.net.ssl.trustStoreType=Windows-ROOT, it would look like this:

JAVA_OPTIONS=("-DAPP_DIR=$APPDIR" "-Djavax.net.ssl.trustStoreType=Windows-ROOT")

Unfortunately, I really don't know anything about Java. Maybe someone else here will be able to provide some advice on that.

I solved this problem for my Kubuntu 21.04.
By the way, your explanation of Bash-style list helped.

In my case, problem occurs under corporate proxy with self-signed certificate. So, main problem to add my company' certificate to Java keystore.

What i did to fix this problem:

  1. Download your certificate, it can be done via browser (in my case Google Chrome):
    Lock Icon before url field -> Certificate -> Details Tab -> Pick your certificate in list (in my case sec.my-company . domain) -> Click 'export' -> Choose save location.
    7-screenshot

  2. Upload your certificate to OS origin solution

  • Go to /usr/local/share/ca-certificates/
  • Copy the exported previously .crt file into this folder
  • Run "sudo update-ca-certificates"
  1. Install openjdk-8. Here i can't give proper advice which version you need, but i used this one below, i am on Kubuntu 21.04 as i said.
sudo apt install openjdk-8-jre-headless
  1. Remove old certificates and update with new ones, origin source
sudo rm /etc/ssl/certs/java/cacerts
sudo update-ca-certificates -f
  1. Open 'arduino' configuration with any text editor (located in untarred folder, named 'arduino-'), find this line:
JAVA_OPTIONS=("-DAPP_DIR=$APPDIR")

and change it to this line:

JAVA_OPTIONS=("-DAPP_DIR=$APPDIR" "-Djavax.net.ssl.trustStore=/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts")

Note, that folder java-8-openjdk-amd64 may be different dependent of your installation.

  1. Re-launch Arduino and check result by going Tools -> Board Manager.
1 Like

I'm very glad to hear that you got it working. Thanks for taking the time to share your findings!
Regards, Per

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.