Java 无法从Spring集成出站网关调用HTTPS端点
我有两个微服务和一个网关。一个微服务是用JHipster和spring boot(Service1)开发的,另一个是spring集成框架(IntegrationService)。现在我需要从IntegrationService调用Service1API。我在两个微服务中都使用HTTPS进行通信。但是当调用API时,我得到了以下错误日志 2021-05-05 11:05:45.503信息22105-[XNIO-1任务-4]c.m.a.s.IntegrationService:IntegrationService org.springframework.messaging.MessageHandlingException中的异常:URI的HTTP请求执行失败[https:///gateway/services/service1/api/viewrecords?id=100100100100157]在[bean'outboundGateway';在“类路径资源[com/esi/app/service/IntegrationService.class]”中定义;来源:org.springframework.core.type.classreading。SimpleMethodMetadata@3fa2213'];嵌套异常为org.springframework.web.client.ResourceAccessException:GET请求时发生I/O错误"https:///gateway/services/service1/api/viewrecords":PKIX路径生成失败:sun.security.provider.certpath.SunCertPathBuilderException:找不到请求目标的有效证书路径;嵌套异常为javax.net.ssl.SSLHandshakeException:PKIX路径生成失败:sun.security.provider.certpath.SunCertPathBuilderException:找不到请求的有效证书路径ested目标,failedMessage=GenericMessage[payload={custId=100157},标头={http_requestMethod=GET,errorChannel=org.springframework.messaging.core.GenericMessageTemplate$TemporaryReplyChannel@703c6baf,连接=保持活动状态,主机=:端口,接受=/,授权=承载者JxVOkq6XOmhUV05LnQj10puEGotcJk1EUlYDvt4n2dAJFSuR3evnvHA,replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@703c6baf,http_requestUrl=http://:/api/getrecordsfromservice1?transactionId=1111111&id=100100157,id=1eec8d00-4040-c9b2-cdb1-4f2d8743d007,内容长度=0,http_用户原则ipal=org.springframework.security.authentication。UsernamePasswordAuthenticationToken@143b9e60:Principal:org.springframework.security.core.userdetails。User@586034f:用户名:admin;密码:[受保护];Enabled:true;AccountNoneExpired:true;CredentialsNoneExpired:true;AccountNonLocked:true;授予的权限:ROLE_ADMIN,ROLE_USER;凭据:[受保护];Authenticated:true;详细信息:null;授予的权限:ROLE_ADMIN,ROLE_USER,accept encoding=gzip,deflate,br,USER agent=PostmanRuntime/7.28.0,timestamp=1620192945487}] 我用来调用IntegrationService的API端点是 https:///gateway/services/integration/api/getrecordsfromservice1?transactionId=1111111111&id=100100100100157 integration是在IntegrationService的网关中注册的服务名称。同样,service1也适用于service1 我无法理解的是:Java 无法从Spring集成出站网关调用HTTPS端点,java,spring-boot,spring-integration,spring-integration-http,Java,Spring Boot,Spring Integration,Spring Integration Http,我有两个微服务和一个网关。一个微服务是用JHipster和spring boot(Service1)开发的,另一个是spring集成框架(IntegrationService)。现在我需要从IntegrationService调用Service1API。我在两个微服务中都使用HTTPS进行通信。但是当调用API时,我得到了以下错误日志 2021-05-05 11:05:45.503信息22105-[XNIO-1任务-4]c.m.a.s.IntegrationService:Integration
@ServiceActivator(inputChannel=“channelOutbound”)
@豆子
公共HttpRequestExecutingMessageHandler outboundGateway(){
最终HttpRequestExecutingMessageHandler=新HttpRequestExecutingMessageHandler(
viewrecordsEndpoint+“{id}”);
setExpectedResponseType(String.class);
setHttpMethod(HttpMethod.GET);
setOutputChannelName(“channelOutboundResponse”);
final ExpressionParser=new SpelExpressionParser();
最终表达式exp=parser.parseExpression(“有效负载[id]”);
final-Map-uriExp=new-HashMap();
uriExp.put(Constants.ID,exp);
setUriVariableExpressions(uriExp);
返回处理程序;
}
@豆子
公共HttpRequestHandlingMessagingGateway inboundGateway(){
最终HttpRequestHandlingMessagingGateway=新HttpRequestHandlingMessagingGateway();
setRequestMapping(requestMapping());
gateway.setRequestChannelName(“channelInbound”);
gateway.setReplyChannelName(“channelInboundReply”);
gateway.setErrorChannelName(“channelInboundError”);
返回网关;
}
私有请求映射getgoldloansforuccinboundrequestmapping(){
final RequestMapping=new RequestMapping();
setPathPatterns(“/api/getrecordsfromservice1”);
setMethods(HttpMethod.GET);
回归映射;
}
Spring集成与HTTPS无关。它是标准的SSL Java配置,必须在两侧正确提供。仅将HTTP模式更改为HTTPS是不够的
在Internet上查看一些可能的解决方案:
关于url的问题。这可能就是API网关的工作原理。因此,当外部请求到达其端点时,它只会剥离自己的上下文