如何从iOS Objective-C在AWS中生成签名?

时间:2018-01-04 11:18:54

标签: ios objective-c iphone amazon-web-services amazon-s3

请提供一些用于生成iOS签名的演示或示例。 https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html 链接不包含objective-c中的任何示例。

3 个答案:

答案 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)

有多种创建declare sqlStr string; sqlStr = 'SELECT 1 AS column1, 2 AS column2 INTO #temp FROM system.iota'; execute immediate sqlStr; select * from #temp;

的方法
  1. AWS SDK
  2. 的帮助下
  3. 借助开源代码共享here

对于 AWS SDK,以下功能会有所帮助

Authorization