camel 支援htts接入概述
camel 版本 :2.14.4
接入服務預設支援https服務接入,預設采用tls1.2協定;
協商階段發送sslv2 hello消息;
目前測試接入camel https consumer沒問題,但是接入tomcat尚不支援,需要tomcat和camel額外配置方能支援。
tomcat https接入問題
現象
camel日志報 “javax.net.ssl.SSLException: Received fatal alert: handshake_failure”,然後連接配接就斷開了。
原因
- jetty(version 8.xx.xx)預設發起的sslv2 hello
- tomcat預設配置不支援 sslv2 hello
解決辦法
對應原因也有兩個方法
- 配置tomcat支援sslv2 hello消息
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2,SSLv2Hello"
clientAuth="false"
sslProtocol="TLS"
keystoreFile="/conf/tomcat.keystore"
keystorePass="tomcat" />
參考 http://stackoverflow.com/questions/26488667/tomcat-7-getting-sslv2hello-is-disabled-error-when-trying-to-make-client-server
2.配置jetty不發送sslv2 hello消息
目前僅支援配置發送ssl hello消息,并且不支援信任所有證書,必須将接入服務的證書導入truststore
配置如下
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camel:sslContextParameters id="mySslContext">
<camel:secureSocketProtocols>
<camel:secureSocketProtocol>TLSv1.1</camel:secureSocketProtocol>
</camel:secureSocketProtocols>
<camel:trustManagers>
<camel:keyStore resource="/conf/keystore/jetty.truststore" password="xxxx"/>
</camel:trustManagers>
</camel:sslContextParameters>
</beans>
工具
- java https調試參數
-Djavax.net.debug=all 這貨可以直接給出錯誤原因,不支援的hello協定,不支援的算法等等
- wireshark
wireshark 預設僅對443端口的流進行https分析,需要在 設定-》協定-》http-》ssl/tsl ports
不設定的話根本觀察不到https的協商過程。