使用带有嵌入式 Jetty 的 Spring-Boot 在 Camel 其余组件上配置 SSL
几天来我一直在努力让 SSL 与现有的休息端点一起工作.目前在 jks 中使用自签名证书.
Been bashing my head in for a few days trying to get SSL working with an existing rest endpoint. Currently using self-signed certificates in a jks.
我们有一条休息路线(不是这条路线,但非常相似):
We have a rest route (not this route, but very similar):
@Override
public void configure() {
restConfiguration()
.component("jetty")
.scheme("https")
.bindingMode(RestBindingMode.off)
.dataFormatProperty("prettyPrint", "true")
.port(8443);
rest("/post")
.post()
.consumes("application/json")
.produces("application/json")
.to( // next endpoint // );
这可以通过 HTTP 完美运行.当我们将方案设置为 HTTPS 时,Jetty 在向其发送请求时会抛出 SSL 密码不匹配错误;我想这是因为没有选择 SSL 配置.
This works perfectly over HTTP. When we set the scheme as HTTPS, Jetty throws a SSL cypher mismatch error when a request is sent to it; I'd imagine this is because no SSL configuration is being picked up.
我已经尝试过互联网上的一些示例(例如从 application.properties 配置 Jetty),但实际上似乎没有任何作用.
I've tried some of the examples on the internet (such as configuring Jetty from the application.properties), but that doesn't actually seem to do anything at all.
感谢任何帮助,项目中的所有路由都是使用 Camel Java DSL 编写的,而不是等效的 XML.
Any help appreciated, all of the routes in the project are written using the Camel Java DSL, not the XML equivalent.
此问题已得到修复.我们发现这样做的正确方法是配置嵌入式 Jetty 本身,而不是修改骆驼路线.这可以通过实例化 JettyHttpComponent 并在其上设置 SSLContextParameters 来实现.
This has since been fixed. We discovered that the correct method of doing this was by configuring the embedded Jetty itself, rather than modifying the camel route. This was achievable by instantiating a JettyHttpComponent, and setting the SSLContextParameters on it.