blue-sky blue-sky - 2 months ago 16x
Scala Question

Receiving (Scala) after installing cert

I'm attempting to download the content of with this code :"", "ISO-8859-1").mkString

This throws exception :

Caused by: PKIX path building failed: unable to find valid certification path to requested target
at Source)
at Source)
at Source)

To fix I export the certificate from via Chrome. I assign alias 'slashdot' and name the vert file 'cert'. I install using command

keytool -import -trustcacerts -keystore cacerts -storepass changeit -noprompt -alias slashdot -file cert.cer
The certificate is imported successfully but same exception is thrown when I attempt to save URL :"", "ISO-8859-1").mkString

Have I missed a step installing the cert ?

Do I need to specify the "Certification path" as part of downloading the content as specified for the cert :

enter image description here

Update :

I thought this could be related to my Scala setup but Java code below throws same error :

import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.Path;

public class download {
public static void main(String args[]) throws Exception{
URL website = new URL("");
Path target = new"c:\\download\\myfile.txt").toPath();

try (InputStream in = website.openStream()) {
Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING);


I'm not 100% sure why I needed to explicitly set the path of cert file but this works :

System.setProperty("", "C:\\java\\jdk1.8.0_65\\jre\\lib\\security\\cacerts");

The comments offered to this question attributed to me trying this solution.