2017-02-09 50 views
0

我正在自動運行安全HTTPs其餘呼叫使用。我們有java密鑰庫文件需要通過代碼導入/添加/插入。我嘗試了很多方式來發送POST請求,但沒有成功。

KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream is = new FileInputStream(「」);
ks.load(is,「password」.toCharArray());
需要幫助使用硒自動化HTTPS其餘呼叫

我收到以下錯誤消息。在線程「主要」 javax.net.ssl.SSLHandshakeException握手

異常時

遠程主機關閉連接:遠程主機握手

請解決此問題的幫助時關閉連接。

使用下面的代碼片斷
#HTTPS路徑
字符串urlPath = 「https://xx.xx.xx.xxx:xxxx/」;
String json =「」;
URL url = new URL(urlPath);
HttpsURLConnection connection = null;
connection =(HttpsURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod(「POST」);
connection.setRequestProperty(「Content-Type」,「application/json」);
connection.setRequestProperty(「Accept」,「application/json」);
OutputStreamWriter streamWriter = new OutputStreamWriter(connection.getOutputStream());

回答

0

使用證書和密鑰文件生成.jks。然後在測試中傳遞該.jks文件

+0

歡迎使用StackOverflow!請查看指導[寫一個好答案](https://stackoverflow.com/help/how-to-answer) – AesSedai101