我们在 amazon ec2 ( backend.abc.com & frontend.abc.com )上运行 2 个应用程序。对于该应用程序,我们使用了付费 SSL 证书。该证书到期日为2021 年 6 月。但是今天,我们遇到了一个错误——
cURL error 60: SSL certificate problem: certificate has expired (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Run Code Online (Sandbox Code Playgroud)
我们检查了证书有效期,但没有问题(2021 年 6 月)。然后我们按照这个线程 - curl:(60)SSL证书问题:无法获得本地颁发者证书(@Dahomz答案)
之后,当我们通过 - 卷曲 abc.com 时curl -v --url https://backend.abc.com --cacert /etc/ssl/ssl.cert/cacert.pem,它工作正常。像这样的回应——
* Rebuilt URL to: https://backend.abc.com/
* Trying 127.0.0.1...
* Connected to backend.abc.com (127.0.0.1) port 443 (#0)
* found 139 certificates in /etc/ssl/ssl.cert/cacert.pem
* found 600 certificates in /etc/ssl/certs
* ALPN, offering …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过 cURL(我可以在几天前访问)访问内部站点。但是,cURL 给出了错误curl: (60) SSL certificate problem: certificate has expired。如果我openssl用来检查证书的开始和结束日期,它会给出一个我很好的时间范围:
echo | openssl s_client -connect internalsite.example.com:443 2>/dev/null | openssl x509 -noout -dates
notBefore=Nov 30 00:00:00 2012 GMT
notAfter=Mar 30 12:00:00 2016 GMT
# For reference, the day I'm posting this is July 30th, 2014
Run Code Online (Sandbox Code Playgroud)
此外,如果我在另一台计算机上使用 cURL,或通过浏览器(Firefox、Chrome 或 IE)进行连接,则可以正常连接。
另外,我无法在自己的计算机上连接任何版本的 cURL;这包括虚拟机内的 Cygwin 中的 cURL 和 Ubuntu 上的 cURL,以及 Windows 版本。
什么可能导致这种行为?
在我的 Node.js 代码中,我使用库请求站点request:
const httpReq = require("request")
function postJSON(uri, data, headers) {
if (uri.slice(-1) != "/") {
uri += "/"
}
console.log(`[postJSON] uri: ${uri}`)
console.log(`[postJSON] body: ${JSON.stringify(data, null, 2)}`)
console.log("[postJSON] headers", JSON.stringify(headers, null, 2))
return new Promise((resolve, reject) => {
httpReq(
{
method: "POST",
uri: uri + Math.floor(Math.random() * 100000000).toString(),
headers: headers,
json: data
}, function (err, resp, body) {
console.log(`[postJSON] done with error: ${err} -> ${uri}`)
if (err) {
reject(err)
}
else {
resolve(body)
}
}
) …Run Code Online (Sandbox Code Playgroud)