我编写了一个包含 WooCommerce API 的快速 API。
当我从我的电脑开发应用程序时,我没有遇到任何问题。但是知道我把它放在一个带有乘客的 Apache 服务器上,它位于像 api.example.com 这样的子域上,它会返回这个错误:
{
"message": "certificate has expired","name": "Error","stack": "Error: certificate has expired\n at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)\n at emitNone (events.js:106:13)\n at TLSSocket.emit (events.js:208:7)\n at TLSSocket._finishInit (_tls_wrap.js:639:8)\n at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)","config": {
"url": "https://example.com/wp-json/wc/v3/orders","method": "get","params": {
"per_page": 100
},"headers": {
"accept": "application/json","User-Agent": "WooCommerce REST API - JS Client/1.0.1"
},"auth": {
"username": "_","password": "_"
},"transformRequest": [
null
],"transformResponse": [
null
],"timeout": 0,"responseType": "json","xsrfCookieName": "XSRF-TOKEN","xsrfHeaderName": "X-XSRF-TOKEN","maxContentLength": -1,"responseEncoding": "utf8"
},"code": "CERT_HAS_EXPIRED"
}
当我直接从服务器卷曲 API 时,它返回给我:
curl https://example.com/wp-json/wc/v3/orders/400 -u consumer_key:consumer_secret
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it,please visit the web page mentioned above.
如果之前没有告诉我,这个错误怎么会是真的?
这是我的域 SSL 配置。