简体   繁体   English

Java-JAX-WS客户端的SSL证书

[英]Java - ssl certificate with JAX-WS client

I have imported the self sign certificate from the server using keytool and all work well. 我已经使用keytool从服务器导入了自签名证书,并且一切正常。

Problem is that it works only when the CN name is use "example.corp.org" for the https: url with JAX-WS client. 问题是,仅当CN名称使用JAX-WS客户端的https:URL使用“ example.corp.org”时,它才有效。 I get an error if i try to use the server IP address: 如果尝试使用服务器IP地址,则会收到错误消息:

Exception in thread "AWT-EventQueue-0"     com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present

I understand why i am getting the error but for a varies reasons i need to use the server IP address to connect to it and not the CN name. 我知道为什么会收到错误,但是由于种种原因,我需要使用服务器IP地址而不是CN名称来连接它。

Anyone have any suggestions? 有人有什么建议吗?

Thanks Alexis 谢谢亚历克西斯

您应该将主题备用名称添加到证书中

subjectAltName=IP:serverIp

sort of resolve it... found the answer here: https://forums.oracle.com/forums/thread.jspa?messageID=6411944 解决它...在这里找到答案: https : //forums.oracle.com/forums/thread.jspa?messageID=6411944

HostnameVerifier myhostnameverifier = new HostnameVerifier() 
{
@Override
public boolean verify(String urlHostName, SSLSession session) 
{
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(myhostnameverifier);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM