带OpenSSL的HMAC-SHA1 /请求Amazon S3签名
问题描述:
我正在编写一个程序,用libCurl和OpenSSL将文件上传到C中的Amazon S3。要发送请求到亚马逊,我必须签署它 - 用HMAC-SHA1 here amazon doc来解释它。请帮忙,可以用openSSL来完成,如果你知道如何建议?或者我需要使用一些其他的库?带OpenSSL的HMAC-SHA1 /请求Amazon S3签名
答
文档的这一部分解释什么编码为每个请求类型(包括上传文件),有几个例子是好的测试您的请求/哈希: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationExamples
答
如果它的iOS ..
AmazonAuthUtils.h
/**
* Compute a keyed hash of some data with a specified key and algorithm.
* @param data The data to sign
* @param key The key to sign the data with
* @param algorithm Which HMAC algortithm to use. Currently support <code>kCCHmacAlgSHA1</code> and <code>kCCHmacAlgSHA256</code>.
* @return Base64 encoded string that is the signature of the data with the specified key.
*/
+(NSString *)HMACSign:(NSData *)data withKey:(NSString *)key usingAlgorithm:(CCHmacAlgorithm)algorithm;
这是你在找什么? http://*.com/questions/242665/understanding-engine-initialization-in-openssl/244310#244310 – mocj
@mocj似乎是那样的功能,谢谢!现在我试图了解到Amazon S3的请求部分应该作为第四个参数传递。没有U与亚马逊API工作? – Hate
对不起,我刚刚在OpenSSL中知道HMAC,因此评论并没有一个完整的答案。我没有使用亚马逊API。什么是第四个参数?如果您引用图形中的ParameterA,它似乎会链接到您的Action参数。如果你的行动不采取任何参数 - 只是把它排除在外。然后附上您的签名。 – mocj