【问题标题】:https4 apache camel gives Host name does not match the certificate subject provided by the peerhttps4 apache camel 给出的主机名与对端提供的证书主题不匹配
【发布时间】:2019-07-22 08:55:02
【问题描述】:

我正在尝试在 Spring DSL 中与 apache camel 建立 https 连接。跟随本教程:https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.2/html/apache_camel_component_reference/IDU-HTTP4

还有:http://camel.apache.org/http4.html

我构造了以下代码:

<sslContextParameters id="sslContextParameters" xmlns="http://camel.apache.org/schema/blueprint"> 
        <trustManagers>
            <keyStore resource="keyStore/keyStore.jks" password="changeit"/>                   
        </trustManagers>                
</sslContextParameters>

还有我的路线:

<route id="axis_camera">
    <to uri = "https4://my_ip_adress?sslContextParametersRef=sslContextParameters"
</route>

<bean id="http-ssl" class="org.apache.camel.component.http4.HttpComponent">
<property name="sslContextParameters" ref="sslContextParameters"/>
</bean>

在 apache servicemix 上运行时,我得到:

javax.net.ssl.SSLPeerUnverifiedException: Host name my_ip_adress does not 
match the certificate subject provided by the peer (CN=axis-accc8ec51452, 
O=Axis Communications AB)

现在我可以在证书中看到此主机名未在主题中定义。我已经看到无法编辑证书,所以我的问题是如何调整此代码以使其读取正确的主机名?

【问题讨论】:

    标签: apache-camel apache-servicemix spring-dsl


    【解决方案1】:

    这是基于现有信息的疯狂猜测,但请尝试一下。 您的证书 CN 是 axis-accc8ec51452,您应该连接到此主机名,而不是 my_ip_address

    要将主机名 axis-accc8ec51452 映射到 my_ip_address,请在您的 DNS 解析器中更新它或将其添加到您的 hosts 文件中(*nix:/etc/hosts | Windows:c:\Windows\System32\Drivers\etc\hosts

    【讨论】:

      【解决方案2】:

      这很令人沮丧,但在@ShellDragon 的帮助下,我搜索了一个允许所有主机名的 bean。这个 bean 是 x509HostnameVerifier。所以在我的代码中我在这里添加了这个:

      <bean id="http-ssl" class="org.apache.camel.component.http4.HttpComponent">
          <property name="sslContextParameters" ref="sslContextParameters"/>
            <property name="x509HostnameVerifier" ref = "x509HostnameVerifier"/>
          </bean>
      

      并将其添加到我的网址:

      https4://my_ip_adress?sslContextParametersRef=sslContextParameters&amp;x509HostnameVerifier=x509HostnameVerifier
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-12-27
        • 1970-01-01
        • 2016-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多