fineuploader chunk signature v4
While trying to upload large file(chunk upload) in signature v4 I get the following error from AWS : SignatureDoesNotMatch The request signature we calculated does not match the signature you provided. Check your key and signing method.
FineUploader headers: {"headers":"AWS4-HMAC-SHA256n20180214T003940Zn20180214/eu-west-3/s3/aws4_requestnPOSTn/foldername/oovoosdk-android-2.3.0.113-1.zipnuploads=nhost:https://test.s3.amazonaws.comnx-amz-acl:privatenx-amz-content-sha256:e3b0c44298fc1c149c897ydu27sas88e56e4649b934ca495991b7852b855nx-amz-date:20180214T003940Znx-amz-meta-filename:oovoosdk-android-2.3.0.113-1.zipnx-amz-meta-qqfilename:oovoosdk-android-2.3.0.113-1.zipnnhost;x-amz-acl;x-amz-content-sha256;x-amz-date;x-amz-meta-filename;x-amz-meta-qqfilenamene3b0c44298fc1c149afbf4c8b92427ae41e464hd783a3dc752b855"}
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
Non chunk upload working fine in signature v4.
v4 signature generation code
StringtoSign --> headers from fine uploader
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/39050.html
上一篇: 通过UPC进行物品查找的亚马逊网络服务
下一篇: fineuploader块签名v4