Utilizzare ExportCertificate con un o AWS SDK CLI - Esempi di codice dell'AWS SDK

Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples GitHub .

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzare ExportCertificate con un o AWS SDK CLI

I seguenti esempi di codice mostrano come utilizzareExportCertificate.

C++
SDKper C++
Nota

C'è altro su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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(); }
CLI
AWS CLI

Per esportare un certificato privato emesso da una CA privata.

Il export-certificate comando seguente esporta un certificato privato, una catena di certificati e una chiave privata sul display:

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

Per esportare il certificato, la catena e la chiave privata in un file locale, utilizzate il seguente comando:

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