简体   繁体   English

Amazon FPS CBUI返回网址验证-PHP

[英]Amazon FPS CBUI Return Url Validation - PHP

I'm trying to run through the Amazon FPS quickstart guide for PHP and am having trouble verifying the return url provided by the CBUI. 我正在尝试浏览PHP的Amazon FPS快速入门指南,并且无法验证CBUI提供的返回URL。

Here is the url: 这是网址:

http://local-screen.com/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php?tokenID=N1G9E5I7BH72563866UZ23YZ1X1AL9AZ2A9291Q1PKDATS8R7BLZ6Y7LEHY2QRHS&signatureMethod=RSA-SHA1&status=SC&signatureVersion=2&signature=WbBPFQku5BA67CR9vWr664eLNDahErYWZM6GrOYTnlDmLZf0rBm0XATrGPLgj5V94GsP0n%2BJ0uye%0A0MRZ3gastZX9M0cjbaPBcCjW1ydt%2BtCiatd%2BjQA6ZRs7XD%2BmWMqHVT3b4eY5WXKHHHQIvp4xLjJY%0AxuwtLf4MaYuiATtdnCY%3D&certificateUrl=https%3A%2F%2Ffps.sandbox.amazonaws.com%2Fcerts%2F090911%2FPKICert.pem%3FrequestId%3Dbjyk7pqb789b33qxg4h9lx8kn8ijplnc5pow0ycey00olslowmv&expiry=01%2F2018&callerReference=%241%24yo8s

This is the error I'm getting: 这是我得到的错误:

Verifying return url signed using signature v2 .... 
Fatal error: Uncaught exception 'Amazon_FPS_SignatureException' with message 'Certificate could not be verified by the FPS service' in /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php:103 Stack trace: #0 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php(50): Amazon_FPS_SignatureUtilsForOutbound->validateSignatureV2(Array, 'http://local-sc...', 'GET') #1 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php(93): Amazon_FPS_SignatureUtilsForOutbound->validateRequest(Array, 'http://local-sc...', 'GET') #2 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php(97): Amazon_FPS_ReturnUrlVerificationSampleCode::test() #3 {main} thrown in /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php on line 103

Here is the function that gets the variables and calls the validation page: 这里是获取变量并调用验证页面中的功能:

public static function test() {

                $aws_access_key = self::$aws_access_key;
                $aws_secret_key = self::$aws_secret_key;

                $utils = new Amazon_FPS_SignatureUtilsForOutbound($aws_access_key, $aws_secret_key);

                /* Verification of an return url signed using signature version 2.*/

                // New parameters sent in return url signed using signature v2
                $params["certificateUrl"] = self::$certificate_url;
                $params["signature"] = self::$signature;
                $params["signatureMethod"] = self::$signature_method;
                $params["signatureVersion"] = self::$signature_version;

                // foreach ($params as $param) {
                //         echo $param;
                //         echo '<br/><br/>';
                // }
                // echo self::$return_url;
                // return;


                $urlEndPoint = self::$return_url; //Your return url end point. 
                print "Verifying return url signed using signature v2 ....\n";
                //return url is sent as a http GET request and hence we specify GET as the http method.
                //Signature verification does not require your secret key
                print "Is signature correct: " . $utils->validateRequest($params, $urlEndPoint, "GET") . "\n";
    }

I also have the output of the foreach loop above which I can PM if somebody needs it. 我也有foreach循环的输出,如果有人需要它,可以在其上面PM。 I just don't understand why I can't validate this url. 我只是不明白为什么我不能验证此网址。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Nick 缺口

I'm using the PHP sample code from Amazon as well, and was running into the exact same error message. 我也使用了Amazon的PHP示例代码,并且遇到了完全相同的错误消息。

Solution

Requirement 1: The value of HttpParameters that you pass in the VerifySignature request must have parameters in the same order as passed to your return URL by Amazon's UI. 要求1:您在VerifySignature请求中传递的HttpParameters值的参数必须与Amazon UI传递给您的返回URL的顺序相同。 So instead of manually fetching each GET parameter as Amazon's sample code does, simply use the $_GET object as the value of the $parameters variable in SignatureUtilsForOutbound.php . 因此,与其像亚马逊的示例代码那样手动获取每个GET参数,不如将$_GET对象用作SignatureUtilsForOutbound.php $parameters变量的值。

Requirement 2: You need to test from a box that is accessible on the Internet. 要求2:您需要从Internet上可访问的盒子中进行测试。 You will always get this error if you're testing from localhost. 如果从本地主机进行测试,则始终会收到此错误。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM