[英]PKIX path building failed:
我正在獲取javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路徑構建失敗:sun.security.provider.certpath.SunCertPathBuilderException:無法找到請求的目標異常的有效證書路徑,如何解決呢?這是我的密鑰庫
KeyStore ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
String pin = " ";
ks.load(null, pin.toCharArray());
Protocol myProtocol = new Protocol("https", new MySSLSockectFactory(), 443);
httpclient.getHostConfiguration()
.setHost("test.euniwizarde.com", 443, myProtocol);
HostConfiguration hostConfiguration = httpclient.getHostConfiguration();
String hostURL = hostConfiguration.getHostURL();
System.out.println("hostURL============" + hostURL);
BufferedReader br = null;
setVisible(false);
PostMethod postMethod = new PostMethod(hostURL);
System.out.println("postmethod " + postMethod);
postMethod.addParameter("userid", "" + userId);
postMethod.addParameter("serialNumber", "" + serialNumber);
postMethod.addParameter("name", "" + name);
postMethod.addParameter("publicKey", "" + publicKey);
postMethod.addParameter("dateOfIssue", "" + dateOfIssue);
postMethod.addParameter("expiry", "" + expiryDate);
postMethod.addParameter("issuer", "" + issuer);
postMethod.addParameter("var", " " + var);
postMethod.addParameter("siteName", "" + siteName);
boolean requestSent = postMethod.isRequestSent();
System.out.println("Is request Sent before execute method===="+ requestSent);
try {
int returnCode = httpclient.executeMethod(postMethod);
您將需要向SSL密鑰庫添加SSL證書。 我假設您正在使用Windows計算機。 您將需要在命令提示符下運行以下命令。
"%JAVA_HOME%\bin\keytool" -import -trustcacerts -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit -alias CERTIFICATE -import -file CERTIFICATE.crt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.