1$ch = curl_init();
2curl_setopt($ch, CURLOPT_URL, $url);
3curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
4curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
5curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
6$data = curl_exec($ch);

注意加 上加亮的这两句,去除 ssl 的验证。

php 手册中这样写:

FALSE to stop CURL from verifying the peer’s certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option. CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2).