I am trying to connect with Paypal
with the following set of code but when I run this code I get following error- .
]
It is working with other URL like google.
Exception in thread "main" 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
Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
@SuppressWarnings({ "deprecation" })
public class HttpURLConnectionExample {
public static void main(String[] args) throws UnsupportedOperationException, IOException {
@SuppressWarnings("unused")
final String USER_AGENT = "Mozilla/5.0";
boolean test = true;
String url = "";
url += (test)? "https://www.sandbox.paypal.com/cgi-bin/webscr?" : "https://www.paypal.com/cgi-bin/webscr?";
String ownerEmail="mail2nkmishra-facilitator-1@gmail.com";
url += "business=" + ownerEmail + "&";
url += "cmd=" + "_xclick" + "&";
url += "amount=" + "20.00" + "&";
url += "item_name=" + "user_signup" + "&";
url += "item_number=" + "item_number" + "&";
url += "quantity=" + "1" + "&";
url += "currency_code=" + "USD" + "&";
url += "no_shipping=" + "1" + "&";
url += "rm=" + "2";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
// add request header
request.addHeader("User-Agent", "Mozilla/5.0");
HttpResponse response = client.execute(request);
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " +
response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
}
}
The problem that you have is your Web Server like apache, weblogic, etc don´t have installed the certify of the paypal like your web browser installed the certify.
ie in weblogic you use the keytool to install the certify you can validate your Signature algorithm in this site sslLabs
This is the scan result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.