/**
* 创建证书
* @param accessKey
* @param secretAccessKey
* @return
*/
private static CreateKeysAndCertificateResult createCertificate(String accessKey,String secretAccessKey){
try {
//获取iot服务客户端,getAmazonIotService此方法请参考(awsIot for Java 创建Iot服务)这篇博文
AWSIot awsIot = IotServiceUtil.getAmazonIotService(accessKey,secretAccessKey);
if(null == awsIot){
LOGGER.error("IotApiUtil.createCertificate 获取iot服务出现异常");
return null;
}
//创建证书
CreateKeysAndCertificateRequest certificateRequest = new CreateKeysAndCertificateRequest();
certificateRequest.setSetAsActive(true);
CreateKeysAndCertificateResult certificateResult = awsIot.createKeysAndCertificate(certificateRequest);
if(null == certificateResult){
LOGGER.error("IotApiUtil.createCertificate 进行iot创建证书未收到返回结果");
return null;
}
return certificateResult;
}catch (Exception e){
LOGGER.error("IotApiUtil.createCertificate",e);
}
return null;
}
awsIot for Java 使用Iot服务,创建证书
最新推荐文章于 2024-05-26 00:19:50 发布