php - PHP curl:(60)SSL证书问题:自签名证书
问题描述
当 PHP 发出 HTTP 发布请求时,会显示一条错误消息。这是我的错误信息:
ttg@pro1-nginx:~$ curl https://10.10.10.20:9997/playwpt/admin
curl: (60) SSL certificate problem: self signed certificate
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.
ttg@pro1-nginx:~$
在测试环境中,使用 nginx 作为 Web 服务。PHP 处理动态请求。在服务器中,我想测试 PHP 发布请求。使用curl命令访问时显示SSL证书有问题
我测试了一个解决方案:
从curl官网下载根证书:cacert.pem,然后修改php.ini添加证书并重启web服务。
将以下内容添加到 php.ini
[SSL]
curl.cainfo = "/etc/php/7.2/cacert.pem"
openssl.cafile = "${curl.cainfo}"
以上方法配置好后,当我在curl命令后面加上“-k”参数时,就可以访问了,但是如果不加这个参数,还是会报上面一样的错误。
这是我的nginx配置:
server{
listen 80;
server_name 10.10.10.40;
index index.html index.htm index.php;
root /usr/share/nginx/html;
location ~ .*\.(php|php5)?${
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .(version.xml|version.fuh|version.fuh.xxx|Boot.swf)${
expires 3m;
}
location ~ .*
(gif|jpg|jpeg|png|bmp|dat|zip|jz|mp3|exe|dds|alpha|rar|spr|dll|pdb|pak|xxx|pck|cur)${
expires 240h;
}
location ~ .*\.(js|css|txt|xml|lua|htm|html|cfg|ini|hlsl|fuh|swf|cab)?${
expires 120m;
}
}
我想要的效果是即使curl命令后面不加“-k”参数也能访问。我怎么解决这个问题?
请帮帮我,谢谢!
解决方案
推荐阅读
- typescript - 环回记录器 4
- python - 有没有办法使用 map 函数或 for 循环来融化?我需要用相同的代码行融化 5 个数据帧
- c# - 如何知道是否在应用程序 C# 中创建了任何表单?
- sql - 填写日期之间的时间,可以不用递归cte来完成吗
- database - 将连接从 MySql DB 更改为 Oracle DB
- mysql - 如何将 MySQL 数据库中的数据放入蛇盒中,并使用 express 将其放入 ejs 列表中每个项目的值字段中
- selenium - 从字符串中删除特定数据
- python - 如何使用 BeautifulSoup 停止文章打印两次
- java - 使用 STAX Parser 将 XML 解组为三个不同对象的列表
- reactjs - 无法处理未捕获的类型错误:无法在 createRouterReducer 读取未定义的属性“位置”