java - Eureka Discovery Client 添加自签名证书
问题描述
我在 Spring Boot 中有几个服务,它们可以将它们自己注册到 eureka 服务器。
这些服务在 http 上运行良好。但是,当我使用 https 时,由于 SSL 验证,客户端注册失败。
如何在 DiscoveryClient 中添加我的自签名 jks 文件以信任 https 证书?
编辑
我的 application.yml 文件
spring:
application:
name: docker-prototype-user-profile
server:
port: 8301
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: https://localhost:8761/eureka/
instance:
hostname: localhost
我的 application.properties 文件
server.ssl.key-store=classpath:keypair.jks
server.ssl.key-store-password=123456
server.ssl.key-password=123456
这里的 jks 文件和 eureka 服务器中的一样。我在所有服务中对 https 使用相同的密钥。由于 jks 文件包含公钥和私钥,因此在这里它用于 2 个目的。一是为此服务的https提供私钥。第二,我想在尤里卡发现客户端中使用它作为证书。
keytool -genkeypair \
-keystore keypair.jks \
-dname "CN=OLEKSIYS-W3T, OU=Sun Java System Application Server, O=Sun Microsystems, L=Santa Clara, ST=California, C=US" \
-keypass 123456 \
-storepass 123456 \
-keyalg RSA \
-keysize 2048 \
-alias default \
-ext SAN=DNS:localhost,DNS:docker-prototype,DNS:docker-prototype-authentication,DNS:docker-prototype-eureka-server,DNS:docker-prototype-post-management,DNS:docker-prototype-secure-service,DNS:docker-prototype-user-management,DNS:docker-prototype-user-profile,DNS:docker-prototype-zuul-gateway \
-validity 9999
使用上述命令生成密钥对
解决方案
推荐阅读
- ruby - QuickBooks API 示例显示了“curl”的用法,但它实际上不起作用或者我错过了什么
- android - Android Studio 上的测验开发
- api - Alpaca API:如何为我的投资组合获取 5 天的数据?
- javascript - 使嵌入在一段时间内改变颜色 discord.js
- swift - @State 更新视图,但 @ObservedObject 不更新
- python - Append 方法在循环中覆盖以前的值
- html - 如何在 CSS 中的 div 中居中两个重叠的圆圈?
- python - 如何获取特定的脚本标签?
- html - 如何更改内部折叠内部具有不同宽度的折叠背景颜色。来自 bootstrap 4.5 的手风琴
- r - 使用 R 将 Stata 16 文件转换为 Stata 12 文件