我有一个授权的SSL连接问题。我已经创建了Struts Action,用客户端授权的SSL证书连接到外部服务器。在我的操作中,我试图将一些数据发送到银行服务器,但没有任何运气,因为我从服务器得到了以下错误:
error: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
我的Action类中将数据发送到服务器的方法
//Getting external IP from host
URL whatismyip = new URL("http://automation.whatismyip.com/n09230945.asp");
BufferedReader inIP = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
String IPStr = inIP.readLine(); //IP as a String
Merchant merchant;
System.out.println("amount: " + amount + ", currency: " + currency + ", clientIp: " + IPStr + ", description: " + description);
try {
merchant = new Merchant(context.getRealPath("/") + "merchant.properties");
} catch (ConfigurationException e) {
Logger.getLogger(HomeAction.class.getName()).log(Level.INFO, "message", e);
System.err.println("error: " + e.getMessage());
return ERROR;
}
String result = merchant.sendTransData(amount, currency, IPStr, description);
System.out.println("result: " + result);
return SUCCESS;
我的merchant.properties文件:
bank.server.url=https://-servernameandport-/
https.cipher=-cipher-
keystore.file=-key-.jks
keystore.type=JKS
keystore.password=-password-
ecomm.server.version=2.0
encoding.source=UTF-8
encoding.native=UTF-8
我第一次认为这是一个证书问题,我将它从.pfx转换为.jks,但我有相同的错误,没有更改。
发布于 2016-09-28 23:16:40
握手失败可能是一个有缺陷的TLSv1协议实现。
在我们的例子中,这对java 7很有帮助:
java -Dhttps.protocols=TLSv1.2,TLSv1.1,TLSv1
jvm将按此顺序进行协商。带有最新更新的服务器将运行1.2,有错误的服务器将运行v1,并且可以与Java7中类似的v1一起工作。
发布于 2016-11-08 09:31:03
发布于 2016-06-17 06:18:09
假设您正在使用正确的SSL/TLS协议,正确配置了您的keyStore
和trustStore
,并且确认证书本身不存在任何问题,那么您可能需要strengthen your security algorithms。
正如在Vineet's answer中提到的,收到此错误的一个可能原因是使用了不兼容的密码套件。通过将JDK文件夹中的local_policy
和US_export_policy
jars更新为Java Cryptography Extension (JCE)中提供的jars,我能够成功地完成握手。
https://stackoverflow.com/questions/6353849
复制相似问题