gpt4 book ai didi

java - SSL 错误 : Unable to verify the first certificate (Nginx -> Spring Boot)

转载 作者:行者123 更新时间:2023-12-04 22:42:12 27 4
gpt4 key购买 nike

我有一个 Ubuntu 虚拟机,我正在尝试为我的域设置来自 PositiveSSL(看起来他们使用 Comodo)的 SSL 证书。
我最初生成了 mywebsite.csr 和 mywebsite.key,然后使用 namecheap 上的 CNAME 记录来验证我的 SSL 证书。验证后,他们通过电子邮件发送给我 mywebsite_com.crt 和 mywebsite_com.ca-bundle。
我在以下位置使用了他们的说明:https://www.namecheap.com/support/knowledgebase/article.aspx/9617/69/how-to-convert-certificates-into-different-formats-using-openssl/
将其转换为 .p12 格式。
我的 application.properties 看起来像:

# The format used for the keystore. It could be set to JKS in case it is a JKS file
server.ssl.key-store-type=PKCS12

# The path to the keystore containing the certificate
server.ssl.key-store=classpath:keystore/mycertificate.p12

# The password used to generate the certificate
server.ssl.key-store-password=redacted

# The alias mapped to the certificate
#server.ssl.key-alias=1

#server.ssl.key-password=redacted

server.ssl.enabled=true
我已经尝试了多种解决方案来设置信任存储别名,但现在这是我的配置。
我的 nginx 服务器配置如下所示:
upstream tomcat{
server localhost:8080;
}

server {
listen 443;
server_name mywebsite.com;

ssl on;
ssl_certificate /root/mywebsite_com.crt;
ssl_certificate_key /root/mywebsite.key;

access_log /var/log/nginx/localhost.access.log main;

location / {
proxy_pass https://tomcat;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
}

当我访问 https://mywebsite.com它在浏览器中运行良好,但是当我从 postman 发出发布请求时,它不断出现“SSL 错误:无法验证第一个证书”的错误
我有一个 3rd 方 webhook 发布到我的网站,它打破了错误:
        "success": false,

"error_class": "RestClient::SSLCertificateNotVerified",

"error_message": "SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)",
我整个周末都在努力解决这个问题,我尝试转换为 .pem、.p7b,制作 keystore.jks,将捆绑包和证书合并到 mywebsite_chain.crt 中。我不知道接下来要尝试什么,请帮忙。

最佳答案

终于解决了!原来使用 nginx 和 spring boot 的证书会导致问题。通过在 Spring Boot 上禁用 ssl 并更改

proxy_pass https://tomcat;
至:
proxy_pass http://tomcat;
问题已解决。

关于java - SSL 错误 : Unable to verify the first certificate (Nginx -> Spring Boot),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67256623/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com