Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android应用程序使用X.509证书连接到AWS物联网_Java_Android_Amazon Web Services_Iot - Fatal编程技术网

Java Android应用程序使用X.509证书连接到AWS物联网

Java Android应用程序使用X.509证书连接到AWS物联网,java,android,amazon-web-services,iot,Java,Android,Amazon Web Services,Iot,我正在编写一个Android应用程序,将传感器连接到AWS物联网服务 我已获得X.509证书、一对公私密钥、clientEndpoint等 我试图遵循AWS的示例代码() 说明很清楚,但我不想生成证书和密钥(我已经有了它们) 下面是代码片段: //创建新的私钥和证书。这个电话 //在服务器上创建并将它们返回到 //装置。 CreateKeysAndCertificateRequest CreateKeysAndCertificateRequest=新建CreateKeysAndCertifica

我正在编写一个Android应用程序,将传感器连接到AWS物联网服务

我已获得X.509证书、一对公私密钥、
clientEndpoint

我试图遵循AWS的示例代码()

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

下面是代码片段:

//创建新的私钥和证书。这个电话
//在服务器上创建并将它们返回到
//装置。
CreateKeysAndCertificateRequest CreateKeysAndCertificateRequest=新建CreateKeysAndCertificateRequest();
createKeysAndCertificateRequest.SetSetSetSetAsActivity(true);
最终CreateKeysAndCertificateResult CreateKeysAndCertificateResult;
createKeysAndCertificateResult=mIotAndroidClient.createKeysAndCertificate(createKeysAndCertificateRequest);
Log.i(Log_标记,“Cert ID:+createKeysAndCertificateResult.getCertificateId()+“created”);
//存储在密钥库中以供MQTT客户端使用
//另存为别名“default”,因此不需要新证书
//生成此应用程序的每次运行
AWSIotKeystoreHelper.saveCertificateAndPrivateKey(certificateId,createKeysAndCertificateResult.getCertificatePem(),createKeysAndCertificateResult.getKeyPair().getPrivateKey(),
keystorePath、keystoreName、keystorePassword);
//将密钥库从文件加载到内存中以继续
//联系
clientKeyStore=AWSIotKeystoreHelper.getIotKeystore(certificateId、keystorePath、keystoreName、keystorePassword);
如何使用现有证书文件而不是生成新的证书和密钥

多谢各位

  • 使用
    AWSIotKeystoreHelper.iskeystorepresentation(mKeystorePath,mKeystoreName)
    检查设备上是否已存在密钥库

  • 使用AWSIotKeystoreHelper.keystoreContainsAlias(mCertificateId、mKeystorePath、mKeystorePassword)检查别名

  • 使用
    keystore=AWSIotKeystoreHelper.getIotKeystore(mCertificateId、mKeystoreName、mKeystorePassword)获取密钥库

  • 使用mqttManager上的密钥库进行连接

  • 使用
    AWSIotKeystoreHelper.iskeystorepresentation(mKeystorePath,mKeystoreName)
    检查设备上是否已存在密钥库

  • 使用AWSIotKeystoreHelper.keystoreContainsAlias(mCertificateId、mKeystorePath、mKeystorePassword)检查别名

  • 使用
    keystore=AWSIotKeystoreHelper.getIotKeystore(mCertificateId、mKeystoreName、mKeystorePassword)获取密钥库

  • 使用mqttManager上的密钥库进行连接