PHP curl:(60)SSL证书问题:自签名证书

PHP curl:(60)SSL证书问题:自签名证书,php,ssl,curl,Php,Ssl,Curl,当PHP发出HTTP post请求时,将显示一条错误消息。以下是我的错误消息: 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 l

当PHP发出HTTP post请求时,将显示一条错误消息。以下是我的错误消息:

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 post请求。使用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”参数,我也可以访问。我怎样才能解决这个问题


请帮帮我,谢谢

您正在尝试通过本地主机运行安全请求吗?如果是这样的话,您可以这样做,但是在本地运行不安全请求(http)并在您的登台环境上模拟安全请求(https)是安全的。这是否回答了您的问题?是的,我想通过本地访问远程网站信息;我只想使用“curl”访问网站内容而不跳过证书