2015-10-23 83 views
2

我想用下面的一组代码连接Paypal,但是当我运行这个代码时,我得到以下错误 - 。PayPal与java的集成

enter image description here]

它正在与其他URL像谷歌。

在线程异常“主要” javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径建设失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到有效的认证路径请求的目标

代码:

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="[email protected]"; 
     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()); 
     } 

    } 

回答

0

,你必须是Web服务器,如Apache中,WebLogic等鸵鸟政策已经安装了贝宝的的Certify喜欢你的网页浏览器的问题,安装的Certify。
即在WebLogic使用密钥工具来安装证明,你可以验证你的签名算法在这个网站sslLabs

这是scan结果

+0

我使用Apache Tomcat,请告诉我如何安装证书 – anubhav

+0

使用此步骤:https://www.digicert.com/ssl-certificate-installation-tomcat.htm –

+0

此答案有帮助吗?不要忘记评价这个问题 –