【发布时间】:2015-09-11 12:07:27
【问题描述】:
我们有一个使用 Apache CXF 制作的客户端,它运行良好,使用特定服务器(即:https://serverexample.com/application/webservice?wsdl)。
但是服务器已经移动到另一个 IP,现在它在同一个 IP 中有两个带有 TLS 和 SNI(服务器名称指示)的 SSL 证书,现在我们的应用程序失败并出现以下错误:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching serverexample.com found
我知道当 https 获得错误的证书(它有另一个服务器名称)时会发生这种情况,因此与我的不匹配。
我试图找出 openssl 发生了什么,并且 URL 仅在我输入 servername 时才有效:
# openssl s_client -connect serverexample.com:443 -tls1
Certificate chain
0 s:/CN=otherserver.com/OU=Servers/O=MyOrganization/C=ES
i:/CN=ACV20/OU=PKACV/O=ACV/C=ES
# openssl s_client -connect serverexample.com:443 -servername serverexample.com
Certificate chain
0 s:/CN=serverexample.com/OU=Servers/O=MyOrganization/C=ES
i:/CN=ACV220/OU=PKACV1/O=ACV2/C=ES
此时生成的apache客户端出现错误:
final URL wsdlURL = new URL("https://serverexample.com/application/webservice?wsdl");
final Operation_Service ss = new Operation_Service(wsdlURL, SERVICE_NAME);
在新的 Operation_Service 中失败:
@WebServiceClient(name = "ENI.Operation",
wsdlLocation = "https://serverexample.com/application/webservice?wsdl",
targetNamespace = "http://inter.ra.es/awrp/wsdl")
public class Operation_Service extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://inter.ra.es/awrp/wsdl", "ENI.Operation");
public final static QName Operation = new QName("http://inter.ra.es/awrp/wsdl", "ENI.Operation");
static {
URL url = null;
try {
url = new URL("https://serverexample.com/application/webservice?wsdl");
} catch (final MalformedURLException e) {
java.util.logging.Logger.getLogger(Operation_Service.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "https://serverexample.com/application/webservice?wsdl");
}
WSDL_LOCATION = url;
}
public Operation_Service(final URL wsdlLocation, final QName serviceName) {
super(wsdlLocation, serviceName);
}
javax.xml.ws.Service 调用 javax.xml.ws.spi.ServiceDelegate,一个抽象类,由 org.apache.cxf.jaxws 中的某个类实现.. 但在这里我失去了它,我没有知道该看什么...
我们的客户端在 weblogic 12.1.1.0 上使用 apache cxf 3.0.4 在 java 7.0 中运行。我读到在 Java 6 中 SNI 存在问题,但我们在这里使用的是 7.0。
我不知道我能做什么。 java 或我们的客户端中是否有一些选项来指示我们尝试连接的服务器名称(如在 openssl 中)?
【问题讨论】:
-
谁能为我提供解决方案:stackoverflow.com/questions/52252184/…
标签: java web-services ssl cxf sni