首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用X.509证书连接到亚马逊IoT的安卓应用程序

使用X.509证书连接到亚马逊IoT的安卓应用程序
EN

Stack Overflow用户
提问于 2019-10-08 20:23:10
回答 1查看 509关注 0票数 1

我正在编写一个Android应用程序来将传感器连接到AWS IoT服务。

我已经获得了X.509证书、一对公钥-私钥、clientEndpoint等。

我正在尝试遵循亚马逊网络服务的示例代码(see here)。

说明很清楚,但我不想生成证书和密钥(我已经有它们了)。

以下是代码片段:

代码语言:javascript
运行
复制
// Create a new private key and certificate. This call
// creates both on the server and returns them to the
// device.
CreateKeysAndCertificateRequest createKeysAndCertificateRequest = new CreateKeysAndCertificateRequest();
createKeysAndCertificateRequest.setSetAsActive(true);
final CreateKeysAndCertificateResult createKeysAndCertificateResult;
createKeysAndCertificateResult = mIotAndroidClient.createKeysAndCertificate(createKeysAndCertificateRequest);
Log.i(LOG_TAG,"Cert ID: " +createKeysAndCertificateResult.getCertificateId() +" created.");

// store in keystore for use in MQTT client
// saved as alias "default" so a new certificate isn't
// generated each run of this application
AWSIotKeystoreHelper.saveCertificateAndPrivateKey(certificateId,createKeysAndCertificateResult.getCertificatePem(),createKeysAndCertificateResult.getKeyPair().getPrivateKey(),
keystorePath, keystoreName, keystorePassword);
// load keystore from file into memory to pass on
// connection
clientKeyStore = AWSIotKeystoreHelper.getIotKeystore(certificateId,keystorePath, keystoreName, keystorePassword);

如何使用现有的证书文件而不是生成新的证书和密钥?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-01-17 21:32:08

  1. 使用AWSIotKeystoreHelper.isKeystorePresent(mKeystorePath, mKeystoreName)检查密钥库是否已位于您的设备上
  2. 使用mqttManager上的keystore = AWSIotKeystoreHelper.getIotKeystore(mCertificateId, mKeystoreName, mKeystorePassword)
  3. Use密钥库检查别名以连接
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58286294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档