0

When PHP makes an HTTP post request, an error message is displayed. Here is my error message:

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:~$ 

In the test environment, nginx is used as a web service. PHP handles dynamic requests. In the server, I want to test PHP post requests. When using curl command to access, it shows that SSL certificate has problems

I tested a solution:

From the official website of curl, download the root certificate: cacert.pem, then modify php.ini to add the certificate and restart the web service.

Add the following to php.ini

[SSL]
curl.cainfo = "/etc/php/7.2/cacert.pem"
openssl.cafile = "${curl.cainfo}"

After the above methods are configured, when I add the "- K" parameter after the curl command, I can access it, but if I do not add this parameter, I will still report the same error above.

Here is my nginx configuration:

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;
         }
    }

The effect I want is that I can access even if I don't add "- K" parameter after curl command. How can I solve this problem?

Please help me, thank you!

Erwin
  • 57
  • 2
  • 7
  • are you trying to run secure requests over your localhost? if thats the case, you could do that, but its safe to run insecure requests (http) locally and mock the safe requests (https) over your staging environment – Ben Yitzhaki Nov 14 '19 at 09:24
  • Does this answer your question? [curl insecure option](https://stackoverflow.com/questions/8520147/curl-insecure-option) – Labradorcode Nov 14 '19 at 09:24
  • Yes, I want to visit remote website information through local; I just want to use "curl https://10.10.10.20:9997/playwpt/admin" to access the website content without skipping the certificate – Erwin Nov 14 '19 at 09:34

0 Answers0