简体   繁体   English

Twilio PHP-SSL证书:证书链中的自签名证书

[英]Twilio PHP - SSL certificate: self signed certificate in certificate chain

I'm struggling with this error when trying to send a message via Twilio using their PHP library : 当尝试使用其PHP库通过Twilio发送消息时,我正在为这个错误而苦苦挣扎:

Fatal error: Uncaught exception Services_Twilio_TinyHttpException with message SSL certificate problem: self signed certificate in certificate chain thrown in F:\path\to\site\twilio-php\Services\Twilio\TinyHttp.php on line 119

I'm using wamp on windows 7. 我在Windows 7上使用了wamp。

I have of course found all of the other posts about certificate errors. 我当然找到了所有其他有关证书错误的信息。 From what I can see, usually updating or adding the cacert.pem file fixes the issue. 据我cacert.pem ,通常更新或添加cacert.pem文件可解决此问题。 However, even after doing this i'm still getting the same error. 但是,即使这样做,我仍然遇到相同的错误。

Just as a sanity check here is exactly what i've done: 就像这里所做的健全性检查一样,这正是我所做的:

  1. Downloaded the latest certificates from here: http://curl.haxx.se/ca/cacert.pem . 从此处下载了最新的证书: http : //curl.haxx.se/ca/cacert.pem
  2. Placed this file in the following location c:/wamp/certs/cacert.pem 将此文件放在以下位置c:/wamp/certs/cacert.pem
  3. Updated php.ini as follows: curl.cainfo = c:/wamp/certs/cacert.pem 如下更新了php.ini: curl.cainfo = c:/wamp/certs/cacert.pem
  4. Restarted all wamp services including apache 重新启动所有wamp服务,包括Apache

And i'm still getting the same error. 而且我仍然遇到相同的错误。 I have verified that I am editing the correct php.ini using phpinfo() . 我已经验证我正在使用phpinfo()编辑正确的php.ini。 I'm at a loss as to why it's still complaining. 我不知道为什么它还在抱怨。

Is there any way to verify 100% that my cacert.pem file is being found and read? 有什么方法可以100%验证是否找到并读取了我的cacert.pem文件? I've checked phpinfo() and there is no mention of it in there. 我已经检查了phpinfo() ,那里没有任何提及。 Should it say somewhere which, if any cacert.pem it's using? 它是否应该在某个地方cacert.pem它正在使用哪个(如果有cacert.pem

Thanks! 谢谢!

I had the exact same issue 我有完全一样的问题

Follow these steps: 跟着这些步骤:

Download the following file - cacert.pem 下载以下文件cacert.pem

Then download the following file - thawte_Premium_Server_CA.pem 然后下载以下文件thawte_Premium_Server_CA.pem

Open the second file in a text editor and copy its contents into the first file ( cacert.pem at the bottom/end). 在文本编辑器中打开第二个文件,然后将其内容复制到第一个文件(底部/末尾的cacert.pem )。

Save cacert.pem and add the following lines to your php.ini : 保存cacert.pem并将以下行添加到您的php.ini

[curl]
curl.cainfo=c:/xampp/php/cacert.pem

Obviously change the directory to the one where your pem is located. 显然,将目录更改为您的pem所在的目录。 Restart the php local server (xampp/wamp). 重新启动php本地服务器(xampp / wamp)。 Then it will work flawlessly. 然后它将完美无缺地工作。

thanks. 谢谢。

Edit TinyHttp.php 编辑TinyHttp.php

and add CURLOPT_SSL_VERIFYPEER => FALSE, at $opts array 并在$ opts数组中添加CURLOPT_SSL_VERIFYPEER => FALSE,

I'm not using Twilio, but I am on Windows and was having the exact problems described in the OP. 我没有使用Twilio,但是我在Windows上并且遇到了OP中描述的确切问题。 I resolved this by downloading the ca-bundle.crt file from this page and pointing my php.ini to it: http://curl.haxx.se/docs/caextract.html 我通过从此页面下载ca-bundle.crt文件并将其php.ini指向它来解决此问题: http : ca-bundle.crt

In my case, the cacert.pem from the download link above didn't work for me but the cacert.pem from previous twilio php library package such as 3.12.5 worked. 就我而言,上面的下载链接中的cacert.pem对我不起作用,但是先前的twilio php库软件包(如3.12.5)中的cacert.pem起作用。 I modified twilio.php in newer package to add the following two lines 我在较新的软件包中修改了twilio.php以添加以下两行

CURLOPT_CAINFO => dirname(FILE) . '/cacert.pem'
'cafile' => dirname(FILE) . '/cacert.pem'

to the corresponding location as older package and copied the cacert.pem to newer package as well. 到旧软件包的相应位置,并将cacert.pem也复制到新软件包。

Instead of hacking tiny_http.php, you can add your own cURL options by calling Twilio's CurlClient constructor with your chosen options, like: 您可以通过使用选定的选项调用Twilio的CurlClient构造函数来添加自己的cURL选项,而不用骇入tiny_http.php,例如:

    $client = new \Twilio\Rest\Client($accountSid, $authToken);
    $curlOptions = [ CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false];
    $client->setHttpClient(new CurlClient($curlOptions));

    try {
        $call = $client->calls->create($from_phone, $phone_number, $callback_url);
        print 'Call queued with Twilio';
    } catch (\Exception $ex) {
        print 'Twilio error: ' . $ex->getMessage();
    }

For me, none of the answers posted here worked. 对我来说,这里发布的答案都无效。

But then I upgraded my PHP to 7.0.1*, and I no longer had this error: Services_Twilio_TinyHttpException: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL 但是后来我将PHP升级到7.0.1 *,并且不再出现以下错误: Services_Twilio_TinyHttpException: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL Services_Twilio_TinyHttpException: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL . Services_Twilio_TinyHttpException: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL

*( C:\\wamp\\bin\\php\\php-7.0.1-Win32-VC14-x64 instead of C:\\wamp\\bin\\php\\php5.4.3 ) *( C:\\wamp\\bin\\php\\php-7.0.1-Win32-VC14-x64代替C:\\wamp\\bin\\php\\php5.4.3

And my C:\\wamp\\bin\\php\\php-7.0.1-Win32-VC14-x64\\php.ini had already included curl.cainfo=C:/wamp/cacert.pem . 我的C:\\wamp\\bin\\php\\php-7.0.1-Win32-VC14-x64\\php.ini已经包含curl.cainfo=C:/wamp/cacert.pem

Here is the official answer from Twilio: 这是Twilio的官方回答:

To try fixing this issue please try to do the following: 要尝试解决此问题,请尝试执行以下操作:

1 Download the following pem file: https://twilio.zendesk.com/attachments/token/EenviU5Rv4KHUzGM6VP5UijB0/?name=cacert.pem 1下载以下pem文件: https ://twilio.zendesk.com/attachments/token/EenviU5Rv4KHUzGM6VP5UijB0/ ? name = cacert.pem

2 Copy this file to either c:\\cert\\cacert.pem (Windows) or any other path on your Unix/ Linux / Mac installation 2将此文件复制到c:\\cert\\cacert.pem (Windows)或Unix / Linux / Mac安装上的任何其他路径

3 Open php.ini file in your favorite editor 3在您喜欢的编辑器中打开php.ini文件

If the following configuration string: curl.cainfo exists in your php.ini, please uncomment it by removing " ; " and modify the path in order to point it to the cacert.pem file attached to this e-mail, eg: 如果您的php.ini中存在以下配置string: curl.cainfo ,请通过删除“ ; ”取消注释,并修改路径以使其指向此电子邮件附带的cacert.pem文件,例如:

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

curl.cainfo=c:\cert\cacert.pem

5 Please restart your Apache service to apply the change (very important!) 5请重新启动您的Apache服务以应用更改(非常重要!)

Adding this answert because nobody is mentioning the [ini-tag] 添加此答案是因为没有人提及[ini-tag]

php.ini php.ini

[curl]
curl.cainfo=C:\cacert.pem

cacert.pem is downloaded here: https://twilio.zendesk.com/attachments/token/EenviU5Rv4KHUzGM6VP5UijB0/?name=cacert.pem cacert.pem在此处下载: https ://twilio.zendesk.com/attachments/token/EenviU5Rv4KHUzGM6VP5UijB0/?name = cacert.pem

I am having the same issue, But I been looking into the article maybe it helps you. 我遇到了同样的问题,但是我一直在研究文章,也许对您有所帮助。 http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

Look into your cURL version. 查看您的cURL版本。 you must be in 7.4x 你必须是7.4倍

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP cURL(SSL证书问题:证书链中的自签名证书) - PHP cURL (SSL certificate problem: self signed certificate in certificate chain) SSL证书错误:在我的Laravel网站上使用Twilio时证书链中的自签名证书 - SSL certificate error: self signed certificate in certificate chain in using Twilio on my Laravel Website CURL错误:SSL证书错误:证书链中的自签名证书 - CURL error: SSL certificate error: self signed certificate in certificate chain PHP Curl 错误:SSL 证书问题:证书链中的自签名证书 - PHP Curl error: SSL certificate problem: self signed certificate in certificate chain PHP cURL 错误:SSL 证书问题:自签名证书 - PHP cURL error: SSL certificate problem: self signed certificate Composer curl 错误 60:SSL 证书问题:证书链中的自签名证书 - Composer curl error 60: SSL certificate problem: self signed certificate in certificate chain "Curl 错误 60,SSL 证书问题:证书链中的自签名证书" - Curl error 60, SSL certificate issue: self signed certificate in certificate chain SSL证书问题:自签名证书 - SSL certificate issue: self signed certificate cURL SSL证书问题:自签名证书Laravel 9 - cURL SSL certificate problem: self signed certificate Laravel 9 自签名认证 SSL 证书的问题 - Issue with self-signed certified SSL certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM