相关疑难解决方法(0)

提供的密钥参数不能使用Google API强制转换为私钥

我正在尝试测试我在此处找到的这个示例,以便我可以在客户端进行直接上传,而无需用户使用Google云端存储进行登录.

表达的所有常量都有正确的值,路径正确且没有空内容.

我得到的错误:

openssl_sign(): supplied key param cannot be coerced into a private key
Run Code Online (Sandbox Code Playgroud)

我实现的功能是:

public static function storageURL( $id, $method = 'GET', $duration = 10 ) {
    $key = file_get_contents(self::KEY_FILE);
    $pkey = openssl_get_privatekey($key, 'notasecret');
    $expires = time( ) + $duration;
    $content_type = ($method == 'PUT') ? 'application/x-www-form-urlencoded' : ''; 
    $to_sign = ($method . "\n" . 
    /* Content-MD5 */ "\n" . 
    $content_type . "\n" . 
    $expires . "\n" . 
    '/'.self::BUCKET_NAME.'/' . $id); 
    $signature = '*Signature will go here*'; …
Run Code Online (Sandbox Code Playgroud)

php google-cloud-storage php-openssl

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

google-cloud-storage ×1

php ×1

php-openssl ×1