我们已经使用Springs HttpInvoker几个星期了,它的功能就像一个魅力。从我的前端(网络)应用程序,我连接到后端的userService这样的:带有https和未签名证书的Spring HTTP调用者
<bean id="userService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://${backend.host}/backend-ws/remoting/UserService"/>
<property name="serviceInterface" value="com...service.UserService"/>
</bean>
的UserService然后很好地注入到我们的前端类。
现在我们将这部署在适当的(WAS7)服务器上,并且需要使用SSL(https)。于是,我改变(的的serviceUrl)的HTTP到HTTPS但后来我得到:
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [https://pbp-dev.dev.echonet/public/backend-ws/remoting/ParameterHelper]; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
,因为在服务器上安装证书这是有道理的(在哪里运行)不是由CA签发的。
我们已经有了一些这方面的经验,因为在同一个WAS上有一个web服务正在运行;为此,我们利用CXF,我们已经产生了JKS文件(密钥工具)驻留在客户端应用程序,并设置如下:
<http:conduit name="https://serverurl/.*">
<http:tlsClientParameters secureSocketProtocol="SSL" disableCNCheck="false">
<sec:trustManagers>
<sec:keyStore type="jks" password="pass123" resource="trust.jks"/>
</sec:trustManagers>
</http:tlsClientParameters>
我想对HTTP调用,我们需要做的事情相似,但我们不知道如何在调用者中使用这个trust.jks。
我发现的一件事是使用不同的requestExecutor;像这样:
<bean id="userService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="https://${backend.host}/backend-ws/remoting/UserService"/>
<property name="serviceInterface" value="com...service.UserService"/>
<property name="httpInvokerRequestExecutor">
<bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor" />
</property>
</bean>
这之后我不再拿到证书错误,但userService似乎没有要创建自那以后,我得到:如果混合使用,你可以在这里找到(HTTP什么
NoSuchBeanDefinitionException: No matching bean of type [com...service.UserService] found for dependency
愿这有助于:http://blog.jayway.com/2008/09/30/spring-remoting-with-security-and-ssl/ – Ralph 2012-01-05 11:51:00
@Ralph, tx,我之前已经看过这个博客,但据我了解,它并未完全解决我们的问题(请参阅本博客的最后一篇文章)。 – 2012-01-05 12:36:05