我是 Spring Boot 的新手。
我正在尝试对服务进行 https 调用,我有一个用于保护连接的 Privake 密钥。
我打:
http://localhost:8081/points/12345/search
我尝试使用 https:// 但我从邮递员那里得到:
Could not get any response
There was an error connecting to https://localhost:8081/points/12345/search.
从我写的那一刻起
server.ssl.key-store=classpath:KeyStore.jks
server.ssl.key-store-password=test
在 application.properties
中,我收到错误消息:
错误请求 - 主机和端口的这种组合需要 TLS
我已经删除了我的控制器中的所有代码,我只是让端点以便我可以调用它。
@RestController
@SpringBootApplication
public class MainApplication {
@RequestMapping(value = "/points/{point}/search", method = RequestMethod.GET)
public PointsType getPoint(@PathVariable(value = "point") String point) {
System.out.println("hi"); // Never printed
return null;
}
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
}
这是文件 application.properties:
spring.application.name=sge
server.port=8081
server.ssl.key-store=classpath:KeyStore.jks
server.ssl.key-store-password=test
server.ssl.key-alias=homologation-staging
server.ssl.trust-store=classpath:TrustStore.jks
server.ssl.trust-store-password=test
server.ssl.client-auth=need
security.require-ssl=true
server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto
我应该怎么办 ?
原文由 Juliatzin 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在开头使用
https://
而不是http://
,它对我有用。