tp6阿里云短信 window 报 cURL error 60: SSL certificate problem: unable to get local issuer certificate

序:帮客户接一个阿里云短信验证码提醒,新版的SDK,一下,折磨简单,在Windows上搞的差点心力交瘁,差点怀疑自己了,还好,收工下班

代码:

// 阿里云短信
public static function createClient($accessKeyId, $accessKeySecret){
    $config = new Config([
        "accessKeyId" => $accessKeyId,
        "accessKeySecret" => $accessKeySecret
    ]);
    // 访问的域名
    $config -> endpoint = "dysmsapi.aliyuncs.com";
    return new Dysmsapi($config);
}
public static function smsTemp($mobile,$code){
    $client = self::createClient(SMS_ID,SMS_SECRET);
    $sendSmsRequest = new SendSmsRequest([
        "signName" => SIGN_NAME,
        "templateCode" => SMS_CODE,
        "phoneNumbers" => $mobile,
        "templateParam" => "{\"code\":\"$code\"}"
    ]);
    // 复制代码运行请自行打印 API 的返回值
    return $client->sendSms($sendSmsRequest);
}
// 测试 API
public function test($mobile,$code){
    $res = self::smsTemp($mobile,$code);
    if($res->body->code == "OK") {
        return "success";
    }
    return 'fail';
}

CA证书,用来在调用HTTPS资源的时候,验证对方网站是否是CA颁布的证书,而不是自己随便生成的;

1、需要下载CA证书 文件地址是 http://curl.haxx.se/ca/cacert.pem

2、将之放到php目录下,并在php.ini 中的 curl.cainfo 后添加路径 :

curl.cainfo="D:\php\cacert.pem"

你可能感兴趣的:(php,短信)