Curl: Fix CURL (51) SSL error: no alternative certificate subject name matches

前端 未结 6 1666
失恋的感觉
失恋的感觉 2020-12-13 01:06

I am new to CURL world, coming from Windows + .NET domain.

Trying to access Rest API for basic authentication at http://www.evercam.io/docs/api/v1/authentication.

6条回答
  •  一生所求
    2020-12-13 01:56

    Editor's note: this is a very dangerous approach, if you are using a version of PHP old enough to use it. It opens your code to man-in-the-middle attacks and removes one of the primary purposes of an encrypted connection. The ability to do this has been removed from modern versions of PHP because it is so dangerous. The only reason this has been upvoted 70 time is because people are lazy. DO NOT DO THIS.


    I know it's a (very) old question and it's about command line, but when I searched Google for "SSL: no alternative certificate subject name matches target host name", this was the first hit.

    It took me a good while to figure out the answer so hope this saves someone a lot of time! In PHP add this to your cUrl setopts:

    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    

    p.s: this should be a temporary solution. Since this is a certificate error, best thing is to have the certificate fixed ofcourse!

提交回复
热议问题