Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支付宝CA证书安装和 openssl_verify 验证失败的问题 #16

Closed
liu-sen opened this issue Sep 28, 2017 · 10 comments
Closed

支付宝CA证书安装和 openssl_verify 验证失败的问题 #16

liu-sen opened this issue Sep 28, 2017 · 10 comments

Comments

@liu-sen
Copy link

liu-sen commented Sep 28, 2017

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
调用转账接口的时候出现这个问题,是什么原因导致的呢?(用的沙箱环境,正式环境没有条件测试)

@yansongda
Copy link
Owner

是 curl 问题,并非类的问题。请检查服务器中 OpenSSL、curl 是否正确安装可正常使用。

麻烦请自行 Google 查看具体原因。

感谢您的支持!

@involvements
Copy link
Contributor

需要在你的 php.ini 中添加 CA 证书:
curl.cainfo = /path/to/downloaded/cacert.pem
cacert.pem 可以从 http://curl.haxx.se/ca/cacert.pem 下载

@liu-sen
Copy link
Author

liu-sen commented Sep 29, 2017

@involvements @yansongda
非常感谢! 上面的问题已经解决了,但新的问题又来了。。。

   /**
     * verify the notify.
     *
     * @author yansongda <me@yansongda.cn>
     *
     * @param array  $data
     * @param string $sign
     * @param bool   $sync
     *
     * @return array|bool
     */
    public function verify($data, $sign = null, $sync = false)
    {
        if (is_null($this->user_config->get('ali_public_key'))) {
            throw new InvalidArgumentException('Missing Config -- [ali_public_key]');
        }

        $sign = is_null($sign) ? $data['sign'] : $sign;

        $res = "-----BEGIN PUBLIC KEY-----\n".
                wordwrap($this->user_config->get('ali_public_key'), 64, "\n", true).
                "\n-----END PUBLIC KEY-----";

        $toVerify = $sync ? json_encode($data) : $this->getSignContent($data, true);

        return openssl_verify($toVerify, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1 ? $data : false;
    }

程序运行到这里时总会返回false,证书应该没有问题呀,为什么会验证失败呢?是因为沙箱环境吗?
The Response content must be a string or object implementing __toString(), "boolean" given.
使用支付宝pos、scan、transfer都是这个问题,web、wap、app都是正常的

@liu-sen liu-sen changed the title 支付宝转账接口的问题 支付宝CA证书安装和 openssl_verify 验证失败的问题 Sep 29, 2017
@yansongda
Copy link
Owner

麻烦请贴出代码,及报错详情。这样发出来很难定位到问题,不是一个有效的提问哦。

同时请参考 #5#8#12

感谢您的支持!谢谢

@liu-sen
Copy link
Author

liu-sen commented Sep 29, 2017

@yansongda
非常抱歉!因为疏忽,公钥填写出错导致的,支付宝公钥填成了应用公钥。。。感谢!

@yansongda
Copy link
Owner

解决就好,感谢支持!

@yansongda
Copy link
Owner

@i838847058 请具体说明麻烦请贴出代码,及报错详情。格式请参考 template。

感谢支持。

@LIJIZHENG
Copy link

image
支付宝

@yishui01
Copy link

Pay::wechat(array_merge($config,['http' => [
'verify' => false, //取消证书验证即可
]]));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@involvements @yansongda @yishui01 @liu-sen @LIJIZHENG and others