0

下面是我正在使用的配置路由,用于调用外部服务。

services_routes.xml

 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">


    <routeContext id="servicesCommonRoutes"
        xmlns="http://camel.apache.org/schema/spring">

        <route id="Route">
            <from uri="direct:route" />
            <marshal>
                <custom ref="Request" />
            </marshal>
            <setHeader name="Content-Type" inheritErrorHandler="true">
                <constant>application/json</constant>
            </setHeader>
            <setHeader name="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <to uri="{{svrRouteEndpoint}}" />
            <unmarshal>
                <custom ref="Response" />
            </unmarshal>
        </route>

    </routeContext>
</beans> 

应用程序属性

svrRouteEndpoint=https://vpce-somehost.awazonaws.com/endpoint
svrApiKey=0123abcd

服务.java

@Autowired
private ProducerTemplate template;
    
 @Value("${svrApiKey}")
private String svrApiKey;


public Response process(Request req, Map<String, Object> headers) throws CamelExecutionException {
    Response response = template.requestBodyAndHeaders("direct:route", req, headers, Response.class);
    return response;
}

 public Map<String, Object> createHeaders(String xWuExternalrefid) {
    Map<String, Object> headers = new HashMap<>();
    headers.put("x-api-key", svrApiKey);
    return headers;
}

问题:

现在,当我尝试使用提供的vpce URL 访问托管在 amazon-aws 上的服务时,使用上述路由。我收到一个带有 {"message" : "Forbidden"} 的 Forbidden 响应代码 = "403"。

除了“ x-api-key ”之外,访问服务不需要其他标头,因此TLS 版本可能在客户端与服务器端不匹配。

我需要使用producerTemplate调用服务,但为此我需要在 Camel Client 上配置/确保TLSv1.2 。

那么如何在service_routes.xml中的我的路由上 配置(xml) TLSv1.2(具有最低配置),以便 producerTemplate/camel 客户端能够访问该服务,并强制 SSL 为 TLSv1.2

4

0 回答 0