使用带有嵌入式 Jetty 的 Spring-Boot 在 Camel 其余组件上配置 SSL [英] Configure SSL on Camel rest-component using Spring-Boot with embedded Jetty

查看:64
本文介绍了使用带有嵌入式 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.

这篇关于使用带有嵌入式 Jetty 的 Spring-Boot 在 Camel 其余组件上配置 SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆