apache camel: 2.15.2
关于rest组件的用法,请参照:http://blog.csdn.net/mn960mn/article/details/48372565
那么,如何配置ssl呢,请继续往下看
一:创建证书
1:创建密钥对
keytool -genkeypair -alias rest -keystore restlet.jks
然后,按照提示,一步一步输入证书信息
2:导出公钥证书
keytool -exportcert -alias rest -keystore restlet.jks -file client.cer
3:把上一步导出的证书导入到浏览器中(可选)
二:在camel里配置ssl的rest,有两种方法
<camel:sslContextParameters id="restSSLContextParameters">
<camel:keyManagers keyPassword="123456">
<camel:keyStore password="123456" type="jks" resource="E:/cert/restlet.jks" />
</camel:keyManagers>
</camel:sslContextParameters>
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="restlet" contextPath="/" port="7722" scheme="https">
<!-- 注意这个value的值,以#号开头 -->
<endpointProperty key="sslContextParameters" value="#restSSLContextParameters" />
</restConfiguration>
<get uri="/ssl/test">
<to uri="direct:aaa" />
</rest>
<route>
<from uri="direct:aaa" />
<setBody>
<simple>this is ssl body</simple>
</setBody>
</route>
</camelContext>
<camel:sslContextParameters id="restSSLContextParameters">
<camel:keyManagers keyPassword="123456">
<camel:keyStore password="123456" type="jks" resource="E:/cert/restlet.jks" />
</camel:keyManagers>
</camel:sslContextParameters>
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="restlet" contextPath="/" port="7722" scheme="https" />
<route>
<from uri="rest:get:/ssl/test?sslContextParameters=#restSSLContextParameters" />
<setBody>
<constant>this is rest ssl body</constant>
</setBody>
</route>
</camelContext>
然后,启动程序,就可以直接访问
https://127.0.0.1:7722/ssl/test
以上是单向认证。
如果需要双向认证的话,则还需要把客户端证书配置上去,示例代码如下:
<camel:sslContextParameters id="restSSLContextParameters">
<camel:keyManagers keyPassword="123456">
<camel:keyStore password="123456" type="jks" resource="E:/cert/restlet.jks" />
</camel:keyManagers>
<camel:trustManagers>
<camel:keyStore password="xxx" resource="xxxx"/>
</camel:trustManagers>
</camel:sslContextParameters>
SpringBoot
Rest
Camel
这是一个基于SpringBoot
Apache
-
Camel
Rest
组件的示例凝乳应用程序。
系统中用于项目设置的必需项:Maven Java 8(如果您具有Java 7,则可以在maven pom中更改source和target属性)
基于H2数据使用,因此不需要数据库。
昂首阔步:Api文档
创建用户: Http方法:POST网址: http://0.0.0.0: /api/users Content-Type = application / json行数据:{“ name”:“ Ankit”}
输出: { "id": 1, "name": "Ankit" }
按ID查找用户
网址:http: : Http方法:GET
例如:http: :
输出: { "id": 1, "name": "Ankit" }
camel
支持htts接入概述接入服务默认支持https服务接入,默认采用tls1.2协议;协商阶段发送
ssl
v2 hello消息;目前测试接入
camel
https consumer没问题,但是接入tomcat尚不支持,需要tomcat和
camel
额外
配置
方能支持。tomcat https接入问题现象
camel
日志报 “javax.net.
ssl
.
SSL
Exception: Received
<dependency>
<groupId>org.
apache
.
camel
</groupId>
<artifactId>
camel
-http4</artifactId>
<version>2.17.1</version>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.
apache
.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:
camel
-cxf="http://
camel
.
apache
.org/schema/blu
apache
camel
随着对灵活的API和微服务的需求的增长,
REST
服务正在成为一种越来越流行的体系结构样式,用于将现代系统与云以及彼此连接。 借助
Apache
Camel
,您可以使用
REST
域特定的语言(DSL)更轻松,更快地编写
REST
服务。
在Grace Hopper庆祝计算妇女大会(2018年9月26日至28日,休斯顿)上的海报发布会上,我们将引导观众逐步使用
REST
DSL开...
<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:schemaL