我正在尝试从这些URL下载
“ https://www.treasury.gov/ofac/downloads/sdn.xml” 而是说
"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"
我尝试过以下两种方法,但是没有用
1. System.setProperty("com.sun.security.enableAIAcaIssuers","true");
2.将我的Java版本从1.7更新为1.8.0_121
download("https://www.treasury.gov/ofac/downloads/sdn.xml","D:\\AML_Files\\Download_Check\\sdnList.xml");
public static void download(String url, String fileName) throws Exception {
//System.setProperty("com.sun.security.enableAIAcaIssuers","true");
try (InputStream in = URI.create(url).toURL().openStream()) {
Files.copy(in, Paths.get(fileName));
}
}
我想在我的系统中下载xml文件,然后将该xml文件数据插入数据库表中
答案 0 :(得分:0)
您需要在JRE中添加有效的证书。