我正在编写一个Android应用程序来将传感器连接到AWS IoT服务。
我已经获得了X.509证书、一对公钥-私钥、clientEndpoint等。
我正在尝试遵循亚马逊网络服务的示例代码(see here)。
说明很清楚,但我不想生成证书和密钥(我已经有它们了)。
以下是代码片段:
// 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);如何使用现有的证书文件而不是生成新的证书和密钥?
谢谢
发布于 2020-01-17 21:32:08
AWSIotKeystoreHelper.isKeystorePresent(mKeystorePath, mKeystoreName)检查密钥库是否已位于您的设备上keystore = AWSIotKeystoreHelper.getIotKeystore(mCertificateId, mKeystoreName, mKeystorePassword)https://stackoverflow.com/questions/58286294
复制相似问题