我正在使用spring来处理微服务,以集中所有请求,然后我更改为使用https。直到现在一切都在正常工作,我创建了我自己签署的证书,并在每个微服务中使用了它,并测试了将GET、POST、DELETE发送到每个微,并且所有的事情都很好,然后当我试图通过spring云网关向微系统发送http请求时,问题就出现了,它显示了这个Bad Request This combination of host and port requires TLS.
。
我使用以下命令生成了我的证书:
keytool -genkeypair -alias statement -keystore src/main/resources/statement-keystore.p12 -keypass secret -storeType PKCS12 -storepass secret -keyalg RSA -keysize 2048 -validity 365 -dname "C=MA, ST=ST, L=L, O=statement, OU=statement, CN=localhost" -ext "SAN=dns:localhost"
春云网关app.yml:
server:
port: 8765
ssl:
enabled: true
key-alias: statement
key-store: classpath:statement-keystore.p12
key-store-password: secret
key-store-type: PKCS12
示例:我在端口8081
上运行了一个微操作,所以如果像这样测试GET请求,它会返回200个并显示数据,但是如果我尝试使用spring https://localhost:8765/api/v1/statemnts
,它会返回This combination of host and port requires TLS.
。
PS:
F 216
提前谢谢。
发布于 2022-10-25 15:27:51
在使用微服务体系结构时遇到了同样的问题,我使用的解决方案是:
这样,您就可以从spring云网关调用您的微服务。希望这个解决方案能为您提供帮助!
https://stackoverflow.com/questions/72447658
复制相似问题