fineuploader块签名v4

在尝试在签名v4中上传大文件(块上载)时,我从AWS获得以下错误:SignatureDoesNotMatch我们计算的请求签名与您提供的签名不匹配。 检查你的密钥和签名方法。

FineUploader标题: {“headers”:“AWS4-HMAC-SHA256 n20180214T003940Z n20180214 / eu-west-3 / s3 / aws4_request nPOST n / foldername / oovoosdk-android-2.3.0.113-1.zip nuploads = n主机:HTTPS://test.s3.amazonaws.com NX-AMZ-ACL:私人 NX-AMZ-内容SHA256:e3b0c44298fc1c149c897ydu27sas88e56e4649b934ca495991b7852b855 NX-AMZ-日期:20180214T003940Z NX-AMZ-元文件名:oovoosdk- android-2.3.0.113-1.zip NX-AMZ-元qqfilename:oovoosdk-android-2.3.0.113-1.zip n n主机; X-AMZ-ACL; X-AMZ-内容-SHA256; X- AMZ-日期; X-AMZ-元文件名X-AMZ-元qqfilename ne3b0c44298fc1c149afbf4c8b92427ae41e464hd783a3dc752b855" }

CanonicalRequest

POST /foldername/oovoosdk-android-2.3.0.113-1.zip uploads = host:test.s3.amazonaws.com x-amz-acl:private x-amz-content-sha256:e3b0c44298fc1c149c897ydu27sas88e56e4649b934ca495991b7852b855 x-amz-date:20180214T010103Z x -amz-meta-filename:oovoosdk-android-2.3.0.113-1.zip x-amz-meta-qqfilename:oovoosdk-android-2.3.0.113-1.zip

host; x-amz-acl; x-amz-content-sha256; x-amz-date; x-amz-meta-filename; x-amz-meta -qqfilename e3b0c44298fc1c149afbf4c8b92427ae41e464hd783a3dc752b855

非签名上传在签名v4中正常工作。

v4签名生成代码

StringtoSign - >来自罚款上传者的头文件

public static String getSignature(AWS_Key_Set__c awsKeySet,String StringtoSign) 
{ String HASH_ALGORITHM = 'SHA-256'; 
String MAC_ALGORITHM = 'HmacSHA256'; 
String SIGNATURE_VERSION = 'AWS4'; 
String SIGNATURE_ALGORITHM = 'AWS4-HMAC-SHA256'; 
String serviceName='s3'; 
Datetime dt = Datetime.now();
String region='eu-west-3'; 
String todayDate = dt.formatGmt('yyyyMMdd');
String now = todayDate + 'T' + dt.formatGmt('HHmmss') + 'Z'; 
Blob keyDate = Crypto.generateMac(MAC_ALGORITHM, Blob.valueOf(todayDate), Blob.valueof(SIGNATURE_VERSION + awsKeySet.AWS_Secret_Key__c)); 
Blob keyRegion = Crypto.generateMac(MAC_ALGORITHM, Blob.valueOf(region), keyDate); 
Blob keyService = Crypto.generateMac(MAC_ALGORITHM, Blob.valueOf(serviceName.toLowerCase()), keyRegion); Blob keyCredentials = Crypto.generateMac(MAC_ALGORITHM, Blob.valueOf('aws4_request'), keyService); 
return EncodingUtil.convertToHex(Crypto.generateMac(MAC_ALGORITHM, Blob.valueOf(StringtoSign), keyCredentials)); 
}
链接地址: http://www.djcxy.com/p/39049.html

上一篇: fineuploader chunk signature v4

下一篇: AWS Pre signed URL