8

I have created a self-signed cert from the instructions on this page, have installed it and it appears to all be working correctly, but now I need cURL to trust it.

Since the later versions of cURL don't include a trusted list within a .pem file, I downloaded the .pem file here and then input this line in php.ini:

curl.cainfo = "C:\xampp\php\cacert.pem"

Now all I need to know is how do I get cURL to trust my self-signed cert? I don't need any browsers to trust it, just cURL.

Brett
  • 319
  • 1
  • 3
  • 12

1 Answers1

7

Seems all I had to do was open up the cacert.pem file and add the contents of the server.crt file to it.

For those reading, server.crt was the file that got created when I created the self-signed cert and which I copied over to: C:\xampp\apache\conf\ssl.crt\server.crt

Brett
  • 319
  • 1
  • 3
  • 12
  • Hi, I tried with above suggested solution and many more options with other blogs, but I am still facing same issue. Kindly suggest – Hiren Soni Jan 19 '17 at 12:34
  • @HirenSoni I would create a new question with your issue and your code so it is easier to narrow down your issue. When doing your `cURL` call you may need to include the path like so.. `curl_setopt($ch, CURLOPT_CAINFO, 'curl_path_here';` – Brett Jan 19 '17 at 14:56
  • thank you for quick response. Actually the issue is, I am using composer to download package and that repo is protected with SSL. So the issue occurred while downloading package with composer. – Hiren Soni Jan 20 '17 at 04:59
  • @HirenSoni In that case it shouldn't have anything to do with using a self-signed SSL cert on your local machine? Sounds like you need the protocol you are using to connect to the repo to trust the SSL cert they are using; probably a bit outside the scope of this question and better to create a new one? – Brett Jan 20 '17 at 08:23
  • Thank you for update, I will try and update in case if I found any solution. – Hiren Soni Jan 20 '17 at 13:01
  • The error message I was getting was: "curl error (#60): ssl certificate problem: self signed certificate". It took a fair amount of searching before finding this post which fixed my problem. I'm hoping that adding the error message will help others to find the solution quicker. My config: Windows 10, Apache 2.4, PHP 8.1 with Apache's virtual host pointing to self-signed server.crt – Leon Jan 25 '23 at 14:13