是否可以在没有HTTPS页面的情况下运行条带测试?我似乎在我的localhost上收到以下错误 . 有没有办法纠正它?
这在提交付款信息后发生 .
致命错误:未捕获异常'Stripe \ Error \ Authentication',消息'Stripe不再支持使用TLS 1.0发出的API请求 . 请使用TLS 1.2或更高版本启动HTTPS连接 . 您可以访问https://stripe.com/blog/upgrading-tls了解更多相关信息 . 在/Applications/MAMP/htdocs/composer/vendor/stripe/stripe-php/lib/ApiRequestor.php:110来自API请求'req_9AwHIpLsRiWhRz'堆栈跟踪:#0 / Applications / MAMP / htdocs / composer / vendor / stripe / stripe -php / lib / ApiRequestor.php(227):Stripe \ ApiRequestor-> handleApiError('{\ n“error”:{\ n ...',401,Array,Array)#1 / Applications / MAMP / htdocs / composer / vendor / stripe / stripe-php / lib / ApiRequestor.php(65):Stripe \ ApiRequestor - > _ interpretResponse('{\ n“error”:{\ n ...',401,Array)#2 / Applications /MAMP/htdocs/composer/vendor/stripe/stripe-php/lib/ApiResource.php(120):Stripe \ ApiRequestor-> request('post','/ v1 / customers',Array,Array)#3 / Applications /MAMP/htdocs/composer/vendor/stripe/stripe-php/lib/ApiResource.php(160):Stripe \ ApiResource :: _ staticRequest('post','/ v1 / custom in / Applications / MAMP / htdocs / composer /第110行的vendor / stripe / stripe-php / lib / ApiRequestor.php
3 回答
这里的问题不是使用HTTPS页面 . 这是您的服务器(本例中为本地计算机)和Stripe之间的TLS通信 . 几个月前,Stripe发布了一篇博文,解释说出于安全原因,他们会弃用一些被认为不安全的旧协议 . 你可以在这里阅读更多相关信息:
https://stripe.com/blog/upgrading-tls
现在,如果您遇到此问题,您的服务器或计算机默认使用TLS 1.0而不是所需的TLS 1.2 .
通常这是由于您的计算机上存在过时的软件或配置问题 . 我建议您查看Stripe的支持文章,其中详细介绍了如何测试代码以及升级路径(包括针对Mac OS和MAMP的一些细节 - 基本上您需要运行应用程序系统php而不是与MAMP捆绑的版本):
https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php
此外,如果您发现系统不支持TLS 1.2,则应升级服务器以正确支持TLS 1.2 . 这可能需要升级操作系统,curl,openssl和/或语言库 .
https://support.stripe.com/questions/how-do-i-upgrade-my-openssl-to-support-tls-1-2
此测试脚本有助于识别PHP安装使用的库版本:https://gist.github.com/olivierbellone/9f93efe9bd68de33e9b3a3afbd3835cf
如果您使用的是3.x版本的PHP库,则可以考虑升级到4.x分支 . 虽然更新系统库是最佳解决方案,但4.x分支允许您传递
CURLOPT_SSLVERSION
标志,这可能允许某些版本的PHP / curl通过TLS 1.2成功通信 .https://github.com/stripe/stripe-php#ssl--tls-compatibility-issues
如果您使用的是Anaconda,以下解决方法适用于我的MAC机器 . 首先,使用conda安装openssl
conda install openssl
然后使用Anaconda管理的python安装创建一个新的虚拟环境 . 在新的虚拟环境中安装您的需求,它应该解决TLS问题 . 使用以下代码进行测试 - source - [https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#python]
使用下面的脚本