Symfonycasts 教程中的 cURL 错误 60

Symfonycasts 教程中的 cURL 错误 60

在 Symfonycasts 中“API 平台:严肃的 RESTful API”第六章有 cURL 命令curl -X GET "https://localhost:8000/api" -H "accept: application/ld+json"。在 Windows 上运行此命令(添加-v)会导致

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying ::1:8000...
* Connected to localhost (::1) port 8000 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self signed certificate in certificate chain
* Closing connection 0
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.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.

在 Linux 系统(Ubuntu 20.04)中,如果现有的 Symfony 项目与上述 Windows 中使用的项目相同,则相同的命令会产生预期的结果{"@context":"\/api\/contexts\/Entrypoint","@id":"\/api","@type":"Entrypoint","nonprofit":"\/api\/nonprofits"}

在两种情况下,命令symfony server:start -dsymfony server:ca:install都已运行。

我认为我需要知道的是如何在 Windows 中添加证书以满足 cURL 的担忧“...curl 无法验证服务器的合法性...”

答案1

如果不完全理解为什么,在 Windows 中使用的命令是:

curl -k "https://localhost:8000/api" -H "accept: application/ld+json"

相关内容