我是 AWS iOS SDK 的新手。我正在尝试使用iPhone 应用程序中的“assumeRole” api 生成临时安全凭证。我在我的项目中添加了 AWSSecurityTokenService、AWSRuntime 框架。下面是代码。
#import <AWSSecurityTokenService/AWSSecurityTokenService.h>
#import <AWSSecurityTokenService/SecurityTokenServiceAssumeRoleRequest.h>
#import <AWSSecurityTokenService/SecurityTokenServiceAssumeRoleResponse.h>
#import <AWSSecurityTokenService/AmazonSecurityTokenServiceClient.h>
- (void)viewDidLoad
{
[super viewDidLoad];
TSC = [[AmazonSecurityTokenServiceClient alloc]init];
request = [[SecurityTokenServiceAssumeRoleRequest alloc]init];
request.roleArn = @"arn:aws:iam::xxxxxxxxxx:role/test";
request.roleSessionName = @"Bob";
request.policy = @"None";
request.durationSeconds=[NSNumber numberWithInt:3600];
request.externalId=@"abc";
//[self assumeRole:request];
@try {
response = [TSC assumeRole:request];
NSLog(@"%@ is response",response);
}
@catch (AmazonClientException *exception) {
NSLog(@" \n\n\nexception %@ \n\n\n", exception);
}
@finally {
NSLog(@"Done");
}
}
我收到以下错误消息和异常。任何帮助,将不胜感激。
objc [1938]:AXEmojiUtilities 类在 /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/PrivateFrameworks/AccessibilityUtilities.framework/ AccessibilityUtilities 和 /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libAXSpeechManager.dylib。将使用两者之一。哪一个是未定义的。2013-01-17 17:16:51.807 AssumeRoleTest[1938:3207] NSURLConnection/CFURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9807) 2013-01-17 17:16:51.810 AssumeRoleTest[1938:c07]
异常 AmazonServiceException { RequestId:(null), ErrorCode:(null), Message:Error Domain=NSURLErrorDomain Code=-1202 “此服务器的证书无效。您可能正在连接到伪装成“sts.amazonaws”的服务器.com”,这可能会使您的机密信息面临风险。” UserInfo=0xa381cb0 {NSErrorFailingURLStringKey= https://sts.amazonaws.com/ , NSLocalizedRecoverySuggestion=您还是要连接到服务器吗?, NSErrorFailingURLKey= https://sts.amazonaws.com/, NSLocalizedDescription=此服务器的证书无效。您可能正在连接到伪装成“sts.amazonaws.com”的服务器,这可能会使您的机密信息面临风险。,NSUnderlyingError=0x8a64a70“此服务器的证书无效。您可能正在连接的服务器是冒充“sts.amazonaws.com”,这可能会使您的机密信息面临风险。", NSURLErrorFailingURLPeerTrustErrorKey=} }
还有一个问题。如何在请求中提供保单详情?我的意思是我可以直接粘贴json格式吗?
{“声明”:[{“效果”:“允许”,“动作”:[“s3:Put*”,“s3:Get*”],“资源”:[“*”]}]}