我正在 VPS 虚拟服务器(ubuntu)上运行 spring-boot jar 应用程序,并且面临证书未知问题。我几乎尝试了一切,但没有成功。
onUncaughtException(SimpleConnection{channel=[id: 0x4e6d10c4 ..... Caused by: javax.net.ssl.SSLHandshakeException: **Received fatal alert: certificate_unknown
**我有来自域的可信证书,我也有中间证书。两者均导入到我的 keystore-certificate.p12 文件中,该文件的地址为
application.properties like this
server.ssl.key-store-type=PKCS12
server.ssl.key-store=/root/myfolder/keystore-certificate.p12
server.ssl.key-store-password=keystore-password
server.ssl.enabled=true
首先导入中间证书,其次导入域证书。证书有效,我已经检查过,所以我不知道什么会导致问题。托管已正确设置 https 协议,因此我可以从 url 中的图标查看证书详细信息。当我从托管发送请求时,这是在标头中
Accept:
application/json, text/plain, */*
Referer:
https://dev-environment.hosting.fun/
Request URL:
https://ipaddress:8080/
Referrer Policy:
strict-origin-when-cross-origin
在 vps 上有允许 8080 的端口,我已经检查过了,我还添加了权限
块引用
密钥库证书.p12
块引用
确保 spring-boot 能够读取内容。
为了获得证书,我使用了 -
sudo certbot certonly --manual --preferred-challenges=dns -d hosting.fun -d dev-
environment.hosting.fun
,然后将其转换为pk12文件,然后导入到keystore-certificate.p12中。
我还缺少什么?
所以,如果有人没有像我这样丰富的经验,这解决了我的问题。
我正在调用 https 不允许的 IP 地址,其中证书中没有 IP 地址,但 CN = 托管的通用名称或其他名称(如果您添加它们)。
因此,您需要在您的主机上设置 DNS 记录,您将在其中添加您尝试调用的远程服务器的 IP 地址和名称,这将反映证书中的名称。那么,您的 Angular 或其他应用程序将不会调用 https://ipaddress,而是调用 https://dev-hosting.com。