2017-08-10 108 views
1

为了与Etsy建立OAuth,我尝试了无数C#解决方案,至少启动身份验证过程(即获取登录URL):Windows Etsy:无法使用给定的CA证书对对等证书进行身份验证

例如

mashery.comhttp://term.ie/oauth/example/client.phpquestion #34

但响应始终是相同的:

oauth_problem=signature_invalid&debug_sbs=GET&https%3A%2F%2Fopenapi.etsy.com%2Fv2%2Foauth%2Frequest_token&oauth_consumer_key%3D...my-consumer-key...%26oauth_nonce%3D2de91e1361d1906bbae04b15f42ab38d%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1502362164%26oauth_version%3D1.0%26scope%3Dlistings_w%2520listings_r

所以我诉诸PHP的可怕的世界......

在我的机器,我已经安装了以下(Windows 10):

XAMPP (xampp-win32-7.1.7-0-VC14-installer) with default options 
    JDK (jdk-8u144-windows-i586) 
    JRE (jre-8u144-windows-i586) 

php_oauth.dll ([php_oauth-2.0.2-7.1-ts-vc14-x86.zip][4]) and copying it to C:\xampp\php\ext 

[cacert.pem][4], (dated Jun 7 03:12:05 2017) and coping it to the following directories: 
      C:\xampp\perl\vendor\lib\Mozilla\CA 
      C:\xampp\phpMyAdmin\vendor\guzzle\guzzle\src\Guzzle\Http\Resources 

Apache和Tomcat将无法运行开始从XAMPP,因为它说,端口443和80人正在使用/受阻,所以我正式在

C:\xampp\apache\conf\extra\httpd-ssl.conf 
C:\xampp\apache\conf\httpd.conf 

改变了这些对444和122的所有好为止,但是当我在浏览器中运行以下脚本(http://localhost:444/dashboard/etsy.php ):

<?php 
    $base_uri = 'https://openapi.etsy.com'; 
    $api_key = 'my-etsy-api-key'; 
    $secret = 'my-etsy-api-secret'; 


    $oauth = new OAuth($api_key, $secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); 
    $req_token = $oauth->getRequestToken($base_uri .= "/v2/oauth/request_token?scope=listings_w%20transactions_r", 'oob'); 

    $login_url = $req_token['login_url']; 
    print "Please log in and allow access: $login_url \n\n"; 

    $verifier = readline("Please enter verifier: "); 
    $verifier = trim($verifier); 
    $oauth->setToken($req_token['oauth_token'], $req_token['oauth_token_secret']); 
    $acc_token = $oauth->getAccessToken($base_uri .= "/v2/oauth/access_token", null, $verifier); 

    $oauth_token = $acc_token['oauth_token']; 
    $oauth_token_secret = $acc_token['oauth_token_secret']; 
    $oauth->setToken($oauth_token, $oauth_token_secret); 

    print "Token: $oauth_token \n\n"; 
    print "Secret: $oauth_token_secret \n\n"; 
?> 

我收到以下错误信息:

Fatal error: Uncaught OAuthException: making the request failed (Peer certificate cannot be authenticated with given CA certificates) in C:\xampp\htdocs\dashboard\etsy.php:8 Stack trace: #0 C:\xampp\htdocs\dashboard\etsy.php(8): OAuth->getRequestToken(' https://openapi ...', 'oob') #1 {main} thrown in C:\xampp\htdocs\dashboard\etsy.php on line 8

我试着运行每个线程安全,OAuth的的x86版(http://windows.php.net/downloads/pecl/releases)脚本 - 停止,重启Apache),但没有运气。

我在我的智慧结束。

如何解决此对等证书问题?

回答

0

只需在本地禁用SSL即可。

$oauth->disableSSLChecks() 

Oauth默认使用CURL SSL证书。本地apache服务器的简单方法是禁用它。为CURL配置SSL。它也将解决oauth的问题。

按照PHP documentation

,我们可以简单的设置证书路径。 $ oauth-> setCAPath(“F:\ xampp \ php \ extras \ ssl \ cacert.pem”); print_r($ oauth-> getCAPath());

如果ssl已经配置,您还可以设置请求引擎为curl或php流。 Official PHP documentation

相关问题