使用AWS SDK碰到的错误,其实很简单,要装个扩展库
保持如下
Fatal error: Uncaught Aws\Auth\Exception\UnresolvedAuthSchemeException: This operation requests `sigv4a` auth schemes, but the client currently supports `sigv4`, `none`, `bearer`, `sigv4-s3express`. in /var/www/html/easymonitor/awstool/aws-sdk-php-v3/Aws/EndpointV2/EndpointV2Middleware.php on line 323
根据提示可以看到如下代码
private function resolveAuthScheme(array $authSchemes): array{$invalidAuthSchemes = [];foreach($authSchemes as $authScheme) {if ($this->isValidAuthScheme($authScheme['name'])) {return $this->normalizeAuthScheme($authScheme);}$invalidAuthSchemes[$authScheme['name']] = false;}.......省略.......throw new UnresolvedAuthSchemeException("This operation requests {$invalidAuthSchemesString}". " auth schemes, but the client currently supports {$validAuthSchemesString}.");}
这里就是判断用哪种验证方式
在头部可以看到sigv4a是在列表里面的
private static $validAuthSchemes = ['sigv4' => 'v4','sigv4a' => 'v4a','none' => 'anonymous','bearer' => 'bearer','sigv4-s3express' => 'v4-s3express'];
这里这个函数isValidAuthScheme就比较可疑
private function isValidAuthScheme($signatureVersion): bool{if (isset(self::$validAuthSchemes[$signatureVersion])) {if ($signatureVersion === 'sigv4a') {return extension_loaded('awscrt');}return true;}return false;}
这里可以看到,列表中有的就直接返回true
但sigv4a比较特殊,需要awscrt扩展
用yum搜了一下有现成的,直接装就行了
总结
缺少awscrt扩展,安装就行了
补充说明
装了扩展还是要添加php文件才行,具体见官方项目
https://github.com/awslabs/aws-crt-php