【问题标题】:Invalid Security Header when adding SSL to Web Service将 SSL 添加到 Web 服务时,安全标头无效
【发布时间】:2012-04-21 22:43:49
【问题描述】:

我们有一个 Web 应用程序,它由向我们的前端开发团队公开的各种 Web 服务组成。我们是一家小商店,所以安全性从来不是我们关心的问题,但我们仍然想知道如何实现它。

我们使用的是 Netbeans 7.0.1、Glassfish 3.1.1 b12 和 SOAP。我们已经通过 Netbeans 中的向导配置了基本的安全性并使其正常工作。然后我们尝试添加传输安全性,并验证它已添加到 WSDL 文件中。当我们尝试添加 SSL 时,我们收到以下错误:

在服务器端:

严重:WSS1601:未满足安全要求 - 策略中配置了传输绑定,但传入消息未启用 SSL 严重:WSITPVD0035:验证入站消息中的安全性时出错。 com.sun.xml.wss.impl.XWSSecurityRuntimeException:WSS1601:未满足安全要求 - 在策略中配置了传输绑定,但传入消息未启用 SSL 在 com.sun.xml.wss.impl.policy.verifier.MessagePolicyVerifier.verifyPolicy(MessagePolicyVerifier.java:125) 在 com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.createMessage(SecurityRecipient.java:983) 在 com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.validateMessage(SecurityRecipient.java:232) 在 com.sun.xml.wss.provider.wsit.WSITServerAuthContext.verifyInboundMessage(WSITServerAuthContext.java:586) 在 com.sun.xml.wss.provider.wsit.WSITServerAuthContext.validateRequest(WSITServerAuthContext.java:360) 在 com.sun.xml.wss.provider.wsit.WSITServerAuthContext.validateRequest(WSITServerAuthContext.java:263) 在 com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:173) 在 com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:144) 在 com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119)

在客户端:

09:36:16,464 警告 [org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor] (http--127.0.0.1-443-1) 请求不包含安全标头,但它是 一个错误。 09:36:16,467 错误 [org.jboss.ejb3.invocation] (http--127.0.0.1-443-1) JBAS014134: EJB 调用在组件 ActivityEJB 上为方法公共 ja 失败 va.util.List com.enginsol.ActivityEJB.getActivities(int): javax.ejb.EJBException: javax.xml.ws.soap.SOAPFaultException: 无效的安全标头 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final.jar:7。 1.0.最终] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final.jar:7 .1.0.最终] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final] 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 在 org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

每个 web 服务在 sun-ejb-jar.xml 中的保护方式基本相同:

<ejb>
        <ejb-name>ActivityWS</ejb-name>
        <webservice-endpoint>
            <port-component-name>ActivityWS</port-component-name>
            <login-config>
                <auth-method>BASIC</auth-method>
            </login-config>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </webservice-endpoint>
    </ejb>

我很确定证书设置已正确完成,因为我们已经清除了与缺少密钥库和错误密钥库密码相关的启动错误。此外,我们最近添加的 RESTful 服务运行良好(弹出用户名/密码对话框并通过 SSL 运行)。客户端和服务器最初都部署到 Glassfish,但我们创建了该服务的小型使用者并将其部署到 JBoss 7.1 以尝试排除 Glassfish 错误。

这是我们可以在 SO 上找到的最接近的答案,而 OP 给出的答案含糊不清,因此我们仍然没有解决方案。 Java Glassfish - How to consume SSL web service?

更新:

我浏览并遵循了 Jim 发布的指南 (http://www.ryandelaplante.com/2007/06/ssl-and-http-basic-authentication-with.html) 并稍微调整了我的设置。我将安全角色添加到 sun-ejb-jar 并将角色允许注释添加到 Web 服务(以前,角色在 sun-application.xml 和另一个 ejb-jar.xml 中处理)。我们的服务是 EJB 端点,所以我浏览了指南中的相关信息,但仍然遇到相同的错误。

【问题讨论】:

    标签: web-services ssl jax-ws glassfish-3


    【解决方案1】:

    您将证书添加到哪里? glassfish 内 domain1/config 目录中的 keystore.jks?您是否将 SSL http 侦听器指向新证书的别名?您是否在 ssl 端口(默认为 8181)上连接到 glassfish?

    【讨论】:

    • 是的,证书已插入到默认 glassfish 密钥库中。我删除了原始的,生成了一个,并用我的全名创建了一个新的。在客户端,我创建了一个新的密钥库并将我的证书导入其中。当客户端只是一个 Java SE 应用程序时,我将证书导入位于 $JAVA_HOME/jre/lib/security 的密钥库中,并显示相同的错误消息。
    • 澄清一下,新证书使用与旧证书相同的别名?我想这就是你要说的。
    • 另外,关于您的证书,您是自己生成的,还是从委托、威瑞信或 thawte 等机构获得的?
    • 对。旧证书具有别名 s1as,因此我将其删除,更改了 Dname 但保留别名以消除 Glassfish 的配置错误。生成所有证书是因为这是用于开发/POC 工作。
    • 您是否在某处收到“pkix 路径构建失败”错误?你可以在客户端试试这个:en.wikibooks.org/wiki/WebObjects/Web_Services/…我在为内部的东西编写测试工具时使用它,因为我没有测试 SSL,我正在测试 Web 服务。您仍然会获得加密流量,只是没有验证证书,这在 dev/poc 情况下似乎没问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-27
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 2014-02-11
    相关资源
    最近更新 更多