我正在尝试使用以下 jsp 代码将数据发布到支付网关网站:
System.setProperty("javax.net.ssl.trustStore ","C:\\Program Files\\Java\\jdk1.7.0_17\\jre\\lib\\security\\cacerts");\
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
URL server = new URL("https://...");
HttpURLConnection connection = (HttpURLConnection) server.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("content-type","application/x-www-form-urlencoded");
connection.connect();
OutputStream os = connection.getOutputStream();
os.write(checkRequestByte);
os.close();
我已使用以下命令将.cer文件添加到 java 密钥库:
keytool -importcert -file "path/certFile.cer" -keystore "Java/jre7/lib/security/cacerts" -alias "Alias"
我也试过这个:
keytool -importcert -file “路径/certFile.cer” -keystore “Java/jdk1.7.0_17/jre/lib/security/cacerts” -alias “别名”
在这两种情况下,我都收到了这条消息:
证书已添加到密钥库
但是当我运行它并打开页面时,我收到以下错误:
org.apache.jasper.JasperException: An exception occurred processing JSP page /process.jsp at line 36
33: connection.setDoOutput(true);
34: connection.setRequestProperty("content-type","application/x-www-form-urlencoded");
35:
36: connection.connect();
37:
38: OutputStream os = connection.getOutputStream();
39: os.write(checkRequestByte);
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty ...
我很困惑,我以前从未遇到过....感谢您的评论