मैं CommWeb नामक एक व्यापारी खाते के साथ एकीकृत कर रहा हूं और मैं अपने यूआरएल (https://migs.mastercard.com.au/vpcdps) में एक एसएसएल पोस्ट भेज रहा हूं।एसएसएल कनेक्शन बनाने के दौरान PKIX पथ निर्माण विफल रहा
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
कोड (जो मैं नहीं लिखा था, और कहा कि पहले से ही हमारे codebase में मौजूद है) कि पोस्ट करता है:
public static HttpResponse sendHttpPostSSL(String url, Map<String, String> params) throws IOException {
PostMethod postMethod = new PostMethod(url);
for (Map.Entry<String, String> entry : params.entrySet()) {
postMethod.addParameter(entry.getKey(), StringUtils.Nz(entry.getValue()));
}
HttpClient client = new HttpClient();
int status = client.executeMethod(postMethod);
if (status == 200) {
StringBuilder resultBuffer = new StringBuilder();
resultBuffer.append(postMethod.getResponseBodyAsString());
return new HttpResponse(resultBuffer.toString(), "");
} else {
throw new IOException("Invalid response code: " + status);
}
}
जब मैं पोस्ट भेजने का प्रयास करें, मैं निम्नलिखित अपवाद
व्यापारी खाता एकीकरण के लिए प्रलेखन प्रमाणपत्रों के बारे में कुछ भी नहीं कहता है। वे कुछ नमूना JSP कोड है कि आँख बंद करके प्रमाण पत्र स्वीकार करने के लिए लगता है प्रदान किया:
<%! // Define Static Constants
// ***********************
public static X509TrustManager s_x509TrustManager = null;
public static SSLSocketFactory s_sslSocketFactory = null;
static {
s_x509TrustManager = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[] {}; }
public boolean isClientTrusted(X509Certificate[] chain) { return true; }
public boolean isServerTrusted(X509Certificate[] chain) { return true; }
};
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
try {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[] { s_x509TrustManager }, null);
s_sslSocketFactory = context.getSocketFactory();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
...
...
// write output to VPC
SSLSocket ssl = (SSLSocket)s_sslSocketFactory.createSocket(s, vpc_Host, vpc_Port, true);
ssl.startHandshake();
os = ssl.getOutputStream();
// get response data from VPC
is = ssl.getInputStream();
...
...
%>
हमारे webapp एक कीस्ट्रोक है, और मैं प्रमाण पत्र (जो मैं फ़ायरफ़ॉक्स से निर्यात) keytool
आदेश का उपयोग कर जोड़ने की कोशिश की, लेकिन वह नहीं था काम और मुझे एक ही त्रुटि मिली। मैंने वेब पर समाधान की कोशिश की है (कुंजी आयात कर रहा है और System.setProperty
का उपयोग कर रहा है) लेकिन ऐसा लगता है कि यह गुंजाइश है और यह काम नहीं करता (मुझे NoSuchAlgorithmError
दिया गया)। किसी भी मदद की सराहना की है!
http://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ/36427118#36427118 – MagGGG