请提供一些用于生成iOS签名的演示或示例。 https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html 链接不包含objective-c中的任何示例。
答案 0 :(得分:0)
您可以参考实施签名请求的AWS SDK for iOS。这是使用AWSCore的AWSSignatureSignerUtility的一个示例。
您可以通过cocoapods获得AWSCore。试试
pod 'AWSCore'
在您的Podfile中。
NSString *aString = @"a random string";
NSString *secretKey = @"aKey";
//unsupport algorithm, should return nil
NSString *signature = [[AWSSignatureSignerUtility HMACSign:[aString dataUsingEncoding:NSUTF8StringEncoding]
withKey:secretKey
usingAlgorithm:kCCHmacAlgMD5] aws_stringWithURLEncoding];
有关SDK的更多信息:https://docs.aws.amazon.com/mobile/sdkforios/developerguide/setup-aws-sdk-for-ios.html
答案 1 :(得分:0)
NSString *aString = @"***********"; NSString *secretKey = @"*********";
NSURL *apiLink = [NSURL URLWithString:@"https://*********"];
AWSStaticCredentialsProvider *creds = [[AWSStaticCredentialsProvider alloc] initWithAccessKey: aString secretKey: secretKey ];
AWSEndpoint *url1 = [[AWSEndpoint alloc] initWithRegion: AWSRegionAPEast1 serviceName: @"APIGateway" URL: apiLink ];
AWSTask *sign = [AWSSignatureV4Signer generateQueryStringForSignatureV4WithCredentialProvider: creds httpMethod: AWSHTTPMethodGET expireDuration: 300 endpoint:url1 keyPath: @"***" requestHeaders:NULL requestParameters:NULL signBody:true];
答案 2 :(得分:0)