【问题标题】:Invalid identity pool configuration in AWSIoTAWSIoT 中的身份池配置无效
【发布时间】:2018-06-04 11:11:50
【问题描述】:

我想在 AWS 上连接到我的客户的 MQTT 服务。我找到了这个Amazon IoT Sample,这节省了我大量时间去挖掘 API 以查找连接 AWS MQTT 服务的过程。

在我的项目中,我更改了Constants.swift 中的常量,以便访问我的客户端的MQTT 服务,如下所示:

let AWSRegion = AWSRegionType.USWest2 // e.g. AWSRegionType.USEast1
let CognitoIdentityPoolId = "us-west-2:e95087f0-48a7-4732-b482-4614c7c63db6"
let CertificateSigningRequestCommonName = "MyApp"
let CertificateSigningRequestCountryName = "MyCountry"
let CertificateSigningRequestOrganizationName = "MyOrganization"
let CertificateSigningRequestOrganizationalUnitName = "MyUnit"
let PolicyName = "pubsub_policy"

// This is the endpoint in your AWS IoT console. eg: https://xxxxxxxxxx.iot.<region>.amazonaws.com

let IOT_ENDPOINT = "https://<endpoint>.amazonaws.com" // endpoint is entered correctly!
let ASWIoTDataManager = "MyIotDataManager"

但是当我按下Connect 时,应用程序会抛出这个错误:

2018-06-04 17:12:59:992 IoTSampleSwift[4999:2464150] 响应正文: {"__type":"InvalidIdentityPoolConfigurationException","message":"无效的身份池配置。检查为此池分配的 IAM 角色。"}

2018-06-04 17:12:59:994 IoTSampleSwift[4999:2464150] GetCredentialsForIdentity 失败。错误是[错误 域=com.amazonaws.AWSCognitoIdentityErrorDomain 代码=5“(空)” UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}]

2018-06-04 17:12:59:995 IoTSampleSwift[4999:2464150] 无法刷新。错误是[错误 域=com.amazonaws.AWSCognitoIdentityErrorDomain 代码=5“(空)” UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}]

2018-06-04 17:13:00:017 IoTSampleSwift[4999:2464150] 错误:错误域 = com.amazonaws.AWSCognitoIdentityErrorDomain 代码 = 5 "(null)" UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}

  • Constants.swift 中的参数有问题吗?
  • 是否可以在我的客户服务中启用某些功能以便我可以访问?
  • 根据10):p12 文件:如果可用,那么我每次需要访问这个MQTT 服务时不必动态创建密钥和证书?但是我的客户必须在他的Amazon AWS IoT Console 上创建它并给我证书/密钥,这样我才能在我的 MAC 上生成这个 p12 文件?

抱歉,由于我是 AWS IoT API 的新手,所以我不得不问这些简单的问题。

问候,

【问题讨论】:

    标签: swift aws-sdk mqtt aws-iot


    【解决方案1】:

    了解您使用的 IoT 身份验证类型会有所帮助。如果您使用 Cognito 进行 AWS IoT 身份验证,那么以下内容肯定会有所帮助。

    在 AWS 的 IAM 控制台中,转到角色。单击您的角色并查看信任关系。这个标签在下图中的位置更容易看出。

    您的 StringEquals 条件的值很可能与您的身份池的值匹配。您可以在 Cognito > Federated Identities > 单击带有“您的身份池名称”的蓝色链接 > 编辑身份池(右上角),您的身份池 ID 位于顶部。如果是这种情况,请单击“编辑信任关系”(如下图所示)并进行编辑,以使“cognito-identit.amazonaws.com::aud”键的值与您的身份池 ID 匹配。

    【讨论】:

      猜你喜欢
      • 2015-08-06
      • 2017-10-18
      • 2020-04-20
      • 2019-07-15
      • 1970-01-01
      • 2020-01-16
      • 1970-01-01
      • 2021-01-11
      • 2012-01-20
      相关资源
      最近更新 更多