gpt4 book ai didi

PayPal Sandbox API SSL 握手错误 HTTPS 请求

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:34 24 4
gpt4 key购买 nike

随着 paypal 的新变化,它开始抛出那些使用旧系统的 SSL 握手异常。 “PayPal SSL 证书变更https://devblog.paypal.com/paypal-ssl-certificate-changes/

这可能对某人有帮助。在我得到 SSL 握手异常之后,我花了很多时间来解决它。

这里是异常:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

解决方案:

解决此问题的要求:

从 1 月 19 日开始,所有沙盒 API 端点都需要

 1.) Use TLS 1.2 and HTTP/1.1 connection

2.) Upgrade to SHA-256 and use the G5 root certificate to make the HTTPS connection

第 1 点解决方案:

If you are using java 6 then better upgrade it to java 7

https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https

For my case i am using java 7 so TLSv1 (default) for JDK 7.

We have to enable it manually while starting server

**-Dhttps.protocols=TLSv1.2** passed as vm argument.

第 2 点解决方案:

https://knowledge.verisign.com/support/mpki-for-ssl-support/index?page=content&actp=CROSSLINK&id=SO5624

G5 cerificate import: Save it as test.cer

Go to java home/bin then run this command

keytool -importcert -file C:/test.cer

创建沙箱帐户。获取服务商密码和签名作为参数传递

String encodedData = "USER=XXX-facilitator_api1.XXX.XXX"
+ "&PWD=XXXXXXXXXXXX"
+ "&SIGNATURE=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-"
+ "&VERSION=95"
+ "&METHOD=SetExpressCheckout"
+ "&PAYMENTREQUEST_0_PAYMENTACTION=Authorization"
+ "&L_PAYMENTREQUEST_0_NAME0="+URLEncoder.encode("Testing","UTF-8")
+ "&L_PAYMENTREQUEST_0_DESC0="+URLEncoder.encode("Testing","UTF-8")
+ "&L_PAYMENTREQUEST_0_AMT0="+URLEncoder.encode("99","UTF-8")
+ "&PAYMENTREQUEST_0_AMT="+URLEncoder.encode("99","UTF-8")
+ "&PAYMENTREQUEST_0_CURRENCYCODE="+URLEncoder.encode("USD","UTF-8")
+ "&LOCALECODE=en_GB"
+ "&RETURNURL=google.com"
+ "&CANCELURL=google.co.in"
+ "&LOGOIMG=imageurl";

String responsepaypal = getHTMLcontent("https://api-3t.sandbox.paypal.com/nvp",encodedData ,"UTF-8");
String token = responsepaypal.toString().replaceAll("TOKEN=(.*?)&TIMESTAMP.*", "$1");//***Token for post request on paypal***




public static String getHTMLcontent(String url,String urlParameters, String encodingDef) throws IOException {

URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-length", String.valueOf(urlParameters.length()));
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36");
con.setRequestProperty("Host", "api-3t.sandbox.paypal.com");
con.setRequestProperty("Upgrade-Insecure-Requests", "1");
con.setRequestProperty("Pragma", "no-cache");
//con.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
con.setRequestProperty("Accept-Encoding", "gzip, deflate, sdch");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.8");
con.setRequestProperty("Connection", "keep-alive");
con.setDoOutput(true);
con.setDoInput(true);
DataOutputStream output = new DataOutputStream(con.getOutputStream());
output.writeBytes(urlParameters);
output.close();

DataInputStream input = new DataInputStream( con.getInputStream() );

StringBuffer sb = new StringBuffer();

String line;
while ((line = input.readLine()) != null) {
sb.append(line);
}

input.close();


return sb.toString();
}}

按照此处明确提到的步骤进行操作:

https://developer.paypal.com/docs/classic/express-checkout/ht_ec-singleAuthPayment-curl-etc/

最佳答案

我正在使用沙盒帐户测试 Paypal ,但我遇到了同样的错误。我升级到 Java 8,错误不再存在。

关于PayPal Sandbox API SSL 握手错误 HTTPS 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35075456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com