与 AWS SDK或ExportCertificate一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

与 AWS SDK或ExportCertificate一起使用 CLI

以下代码示例演示如何使用 ExportCertificate

C++
SDK对于 C++
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

//! Export an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param passphrase: A passphrase to decrypt the exported certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::exportCertificate(const Aws::String &certificateArn, const Aws::String &passphrase, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::ExportCertificateRequest request; Aws::Utils::CryptoBuffer cryptoBuffer( reinterpret_cast<const unsigned char *>(passphrase.c_str()), passphrase.length()); request.WithCertificateArn(certificateArn).WithPassphrase(cryptoBuffer); Aws::ACM::Model::ExportCertificateOutcome outcome = acm_client.ExportCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ExportCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: Information about certificate with ARN '" << certificateArn << "':" << std::endl << std::endl; auto result = outcome.GetResult(); std::cout << "Certificate: " << std::endl << std::endl << result.GetCertificate() << std::endl << std::endl; std::cout << "Certificate chain: " << std::endl << std::endl << result.GetCertificateChain() << std::endl << std::endl; std::cout << "Private key: " << std::endl << std::endl << result.GetPrivateKey() << std::endl; } return outcome.IsSuccess(); }
  • 有关API详细信息,请参阅 “AWS SDK for C++ API参考 ExportCertificate” 中的。

CLI
AWS CLI

导出私有 CA 颁发的私有证书。

以下export-certificate命令将私有证书、证书链和私钥导出到您的显示屏上:

aws acm export-certificate --certificate-arn arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012 --passphrase file://path-to-passphrase-file

要将证书、证书链和私钥导出到本地文件,请使用以下命令:

aws acm export-certificate --certificate-arn arn:aws:acm:region:sccount:certificate/12345678-1234-1234-1234-123456789012 --passphrase file://path-to-passphrase-file > c:\temp\export.txt