I have been fighting this for 2 weeks now and I finally figured it out! I hope this helps where help is needed.
I tinker with stuff during my free time at work and I’m DEEP behind a corporate firewall so I didn’t have much hope since this is usually a deal breaker. But it used to work and our IT department doesn’t care about Arduinos so it SHOULD work. I began having this same issue when I decided to try the new Seeeduino XIAO. I followed the steps to add this entry to my preferences.txt file:
No matter what I tried I could not make the Arduino IDE Boards Manager nor the Library Manager work. A few moments after starting the IDE I got the red error:
"Error downloading http://downloads.arduino.cc/packages/package_index.json."
I tried nearly everything. I even installed VSCode to see if it would work and (now this is odd) I got VSCode’s equivalent of the same problem. Basically if you setup VSCode it should read alot of the configuration from the Arduino IDE and work just fine. Keywords here are “from the Arduino IDE”. So VSCode relies on your Arduino IDE already working perfect. Mine was broke somewhere, or so I thought.
After extensive research I discovered this is a common output from Java. It happens when (in Java land) you don’t have your certificates set up for your SSL. This error response is generated by Java because it is trying to validate your ability to reach out onto the internet and get stuff using a non-browser application. (I’ve seriously condensed what all really goes on.) But suffice to say, you can’t get the files because you don’t have the right certificate.
I’m using Windows 7 with Edge and IE11 but I’ll give the “how-to” for Edge which is close enough.
In Edge navigate to Arduino.cc
Open Settings and type certificates in the search.
Select Manage certificates.
In Certificates use the arrows to the right of the tabs to find the Trusted Publishers tab.
Here you should see an entry for Arduino LLC and Arduino srl unless this is a new installation.
In my case both certificates were expired which was only part of my problem.
Go back to the open tab of Arduino.cc and to the left of the Address “https://www.arduino.cc/” in Edge you will see a closed lock icon.
Right-click on this icon and select “Certificate (valid)”
Select the Details tab
Select “Copy to file…” - Next - Next and enter a filename. Make sure you type an entire path so you can find the file. I typed __*C:\Arduino *__This creates a file called C:\Arduino.cer.
Select Finish and at “export was successful” select OK. and select OK to close the Certificate window.
Now comes the part where hopefully you realize the true source of the problem.
I and most likely you too have Java installed on my computer already. Well guess what. So does Arduino. You most likely have two versions of Java installed which is not supposed to happen but the Arduino IDE contains a full Java Runtime Environment too. To do this right you will need to do this twice if you have two installations of Java like me.
Open a command prompt and copy and paste these two long command lines:
when it asks for a password the standard password here is “changeit” so just enter that and it should work though you might could use anything, don’t. This worked every time.
cd "C:\Program Files (x86)\Arduino\java\bin"
keytool.exe -import -alias Arduino -keystore “C:\Program Files (x86)\Arduino\java\lib\security\cacerts” -file C:\Arduino.cer
Enter the password [changeit]
At Trust this certificate type “yes”. I don’t think it accepts just “y”.
For this next command you will need to know where keytool.exe in your existing java installation. Mine was as shown below but hopefully if you’re this deep you can at least understand where Im going here. You should use the keytool.exe that goes with the version of Java you’re working with. There is a file in “…\lib\security” called “cacerts” that you are adding the new certificate to. And you should do it to both installations of Java. So now enter this if you are using Java 1.8.0_281 or change the line accordingly.
cd “C:\Program Files\Java\jre1.8.0_281\bin”"
keytool.exe -import -alias Arduino -keystore “C:\Program Files\Java\jre1.8.0_281\lib\security\cacerts” -file C:\Arduino.cer
If you receive a keytool error saying it already exists don’t worry. Enter this command then reenter the previous commands:
keytool.exe -delete -alias Arduino -keystore "C:\Program Files\Java\jre1.8.0_281\lib\security\cacerts"
Note that in both instances above I navigated to the bin folder. This is where the keytool.exe is located. Java usually isn’t in your path so you’ll have to be in the corresponding folder to run it.
I hope this gets you out of this hole too so Good Luck.
P.S. This also fixed my problems with VSCode as well.