【问题标题】:wsdl2java CXF command line error about disableCNCheck option关于 disableCNCheck 选项的 wsdl2java CXF 命令行错误
【发布时间】:2011-07-29 13:39:43
【问题描述】:

我正在使用 CXF wsdl2java 命令行工具在 https 连接下从 WSDL 生成 Java 类。 生成过程中一切正常,但是当我调用 WSDL 提供的服务之一时,我得到了这个异常:

java.io.IOException: The https URL hostname does not match the Common Name (CN) on the server certificate. To disable this check (NOT recommended for production) set the CXF client TLS configuration property "disableCNCheck" to true.

这个 disableCNCheck 是我可以在 java 类生成期间设置的吗?似乎不是,或者至少它不是 wsdl2java 的有效选项。

我必须在 wsdl 或我的 (grails) 应用程序中指定什么,它使用生成的 java 类吗?

【问题讨论】:

    标签: grails command-line wsdl cxf


    【解决方案1】:

    事实证明,这与生成时间无关,而是与运行时有关。

    要设置 disableCNCheck 标志,我是这样做的:

    protected void disableCNCheck(Object port) {
        Client client = ClientProxy.getClient(port)
    
        TLSClientParameters params = new TLSClientParameters()
        params.setDisableCNCheck(true)
        HTTPConduit httpConduit = (HTTPConduit) client?.getConduit()
        httpConduit?.setTlsClientParameters(params)
    }
    

    其中端口是用于与受 SSL 保护的 API 服务通信的对象。

    【讨论】:

      【解决方案2】:

      我通过将以下 xml 配置添加到 grails-app/conf/spring/resources.xml [ Grails 2.2.3 , cxf-client plugin 1.6.1] 来实现 disableCNCheck

      <beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xmlns:http="http://cxf.apache.org/transports/http/configuration" 
             xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
                  http://cxf.apache.org/transports/http/configuration
      http://cxf.apache.org/schemas/configuration/http-conf.xsd
            "> 
      
        <http:conduit name="*.http-conduit"> 
          <http:tlsClientParameters disableCNCheck="true" /> 
        </http:conduit> 
      
      </beans> 
      

      【讨论】:

      猜你喜欢
      • 2011-01-13
      • 2021-04-26
      • 2023-03-25
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      • 2020-10-06
      相关资源
      最近更新 更多