0
我有寫一個靜態的POST方法與Apache的HttpClient:HttpClient的患上了「SSL證書錯誤」時,後爲https在GlassFish中的servlet
public class HttpPost {
public static HttpPostResult post(String url, String xml) throws IOException {
Logger.getAnonymousLogger().log(Level.INFO, url + "|" + xml);
HttpClient httpClient = new HttpClient();
HttpPostResult httpPostResult = new HttpPostResult();
PostMethod postMethod = new PostMethod(url);
StringRequestEntity stringRequestEntity = new StringRequestEntity(xml,"xml","utf-8");
postMethod.setRequestEntity(stringRequestEntity);
httpClient.executeMethod(postMethod);
httpPostResult.setStatus(postMethod.getStatusCode());
httpPostResult.setResponseStr(postMethod.getResponseBodyAsString());
return httpPostResult;
}
}
這種方法工作時,我測試了單機就好了,但一旦我把它建到行家的依賴,並在HTTP Servlet中涉及它,它只是不工作,並且響應字符串變成:
<html>
<head><title>400 The SSL certificate error</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The SSL certificate error</center>
<hr><center>nginx</center>
</body>
</html>
似乎遠程主機使用nginx的,我想也許有一些SSL信任問題發生,但遠程主機是可信任的(由可信任機構簽署的CA),它是https://api.mch.weixin.qq.com/pay/orderquery
應該是什麼問題?