搭ExportCertificate配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ExportCertificate配 AWS SDK或使用 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