Seleccione sus preferencias de cookies

Usamos cookies esenciales y herramientas similares que son necesarias para proporcionar nuestro sitio y nuestros servicios. Usamos cookies de rendimiento para recopilar estadísticas anónimas para que podamos entender cómo los clientes usan nuestro sitio y hacer mejoras. Las cookies esenciales no se pueden desactivar, pero puede hacer clic en “Personalizar” o “Rechazar” para rechazar las cookies de rendimiento.

Si está de acuerdo, AWS y los terceros aprobados también utilizarán cookies para proporcionar características útiles del sitio, recordar sus preferencias y mostrar contenido relevante, incluida publicidad relevante. Para aceptar o rechazar todas las cookies no esenciales, haga clic en “Aceptar” o “Rechazar”. Para elegir opciones más detalladas, haga clic en “Personalizar”.

Ejemplos de ACM con SDK para C++ - AWS Ejemplos de código de SDK

Hay más ejemplos de AWS SDK disponibles en el GitHub repositorio de ejemplos de AWS Doc SDK.

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Hay más ejemplos de AWS SDK disponibles en el GitHub repositorio de ejemplos de AWS Doc SDK.

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Ejemplos de ACM con SDK para C++

Los siguientes ejemplos de código muestran cómo realizar acciones e implementar escenarios comunes mediante el uso de AWS SDK for C++ ACM.

Las acciones son extractos de código de programas más grandes y deben ejecutarse en contexto. Mientras las acciones muestran cómo llamar a las distintas funciones de servicio, es posible ver las acciones en contexto en los escenarios relacionados.

En cada ejemplo se incluye un enlace al código de origen completo, con instrucciones de configuración y ejecución del código en el contexto.

Acciones

En el siguiente ejemplo de código, se muestra cómo utilizar AddTagsToCertificate.

SDK para C++
nota

Hay más información al respecto. GitHub Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Add tags to an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::addTagsToCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::AddTagsToCertificateRequest request; Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.WithKey(tagKey).WithValue(tagValue); tags.push_back(tag); request.WithCertificateArn(certificateArn).WithTags(tags); Aws::ACM::Model::AddTagsToCertificateOutcome outcome = acmClient.AddTagsToCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: addTagsToCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: Tag with key '" << tagKey << "' and value '" << tagValue << "' added to certificate with ARN '" << certificateArn << "'." << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta AddTagsToCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar AddTagsToCertificate.

SDK para C++
nota

Hay más información al respecto. GitHub Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Add tags to an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::addTagsToCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::AddTagsToCertificateRequest request; Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.WithKey(tagKey).WithValue(tagValue); tags.push_back(tag); request.WithCertificateArn(certificateArn).WithTags(tags); Aws::ACM::Model::AddTagsToCertificateOutcome outcome = acmClient.AddTagsToCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: addTagsToCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: Tag with key '" << tagKey << "' and value '" << tagValue << "' added to certificate with ARN '" << certificateArn << "'." << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta AddTagsToCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar DeleteCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Delete an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::deleteCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::DeleteCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::DeleteCertificateOutcome outcome = acmClient.DeleteCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: DeleteCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: The certificate with the ARN '" << certificateArn << "' is deleted." << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta DeleteCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar DeleteCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Delete an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::deleteCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::DeleteCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::DeleteCertificateOutcome outcome = acmClient.DeleteCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: DeleteCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: The certificate with the ARN '" << certificateArn << "' is deleted." << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta DeleteCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar DescribeCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Describe an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::describeCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::DescribeCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::DescribeCertificateOutcome outcome = acm_client.DescribeCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: DescribeCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { Aws::ACM::Model::CertificateDetail certificate = outcome.GetResult().GetCertificate(); std::cout << "Success: Information about certificate " "with ARN '" << certificateArn << "':" << std::endl << std::endl; std::cout << "ARN: " << certificate.GetCertificateArn() << std::endl; std::cout << "Authority ARN: " << certificate.GetCertificateAuthorityArn() << std::endl; std::cout << "Created at (GMT): " << certificate.GetCreatedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; std::cout << "Domain name: " << certificate.GetDomainName() << std::endl; Aws::Vector<Aws::ACM::Model::DomainValidation> options = certificate.GetDomainValidationOptions(); if (!options.empty()) { std::cout << std::endl << "Domain validation information: " << std::endl << std::endl; for (auto &validation: options) { std::cout << " Domain name: " << validation.GetDomainName() << std::endl; const Aws::ACM::Model::ResourceRecord &record = validation.GetResourceRecord(); std::cout << " Resource record name: " << record.GetName() << std::endl; Aws::ACM::Model::RecordType recordType = record.GetType(); Aws::String type; switch (recordType) { case Aws::ACM::Model::RecordType::CNAME: type = "CNAME"; break; case Aws::ACM::Model::RecordType::NOT_SET: type = "Not set"; break; default: type = "Cannot determine."; break; } std::cout << " Resource record type: " << type << std::endl; std::cout << " Resource record value: " << record.GetValue() << std::endl; std::cout << " Validation domain: " << validation.GetValidationDomain() << std::endl; Aws::Vector<Aws::String> emails = validation.GetValidationEmails(); if (!emails.empty()) { std::cout << " Validation emails:" << std::endl << std::endl; for (auto &email: emails) { std::cout << " " << email << std::endl; } std::cout << std::endl; } Aws::ACM::Model::ValidationMethod validationMethod = validation.GetValidationMethod(); Aws::String method; switch (validationMethod) { case Aws::ACM::Model::ValidationMethod::DNS: method = "DNS"; break; case Aws::ACM::Model::ValidationMethod::EMAIL: method = "Email"; break; case Aws::ACM::Model::ValidationMethod::NOT_SET: method = "Not set"; break; default: method = "Cannot determine"; } std::cout << " Validation method: " << method << std::endl; Aws::ACM::Model::DomainStatus domainStatus = validation.GetValidationStatus(); Aws::String status; switch (domainStatus) { case Aws::ACM::Model::DomainStatus::FAILED: status = "Failed"; break; case Aws::ACM::Model::DomainStatus::NOT_SET: status = "Not set"; break; case Aws::ACM::Model::DomainStatus::PENDING_VALIDATION: status = "Pending validation"; break; case Aws::ACM::Model::DomainStatus::SUCCESS: status = "Success"; break; default: status = "Cannot determine"; } std::cout << " Domain validation status: " << status << std::endl << std::endl; } } Aws::Vector<Aws::ACM::Model::ExtendedKeyUsage> usages = certificate.GetExtendedKeyUsages(); if (!usages.empty()) { std::cout << std::endl << "Extended key usages:" << std::endl << std::endl; for (auto &usage: usages) { Aws::ACM::Model::ExtendedKeyUsageName usageName = usage.GetName(); Aws::String name; switch (usageName) { case Aws::ACM::Model::ExtendedKeyUsageName::ANY: name = "Any"; break; case Aws::ACM::Model::ExtendedKeyUsageName::CODE_SIGNING: name = "Code signing"; break; case Aws::ACM::Model::ExtendedKeyUsageName::CUSTOM: name = "Custom"; break; case Aws::ACM::Model::ExtendedKeyUsageName::EMAIL_PROTECTION: name = "Email protection"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_END_SYSTEM: name = "IPSEC end system"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_TUNNEL: name = "IPSEC tunnel"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_USER: name = "IPSEC user"; break; case Aws::ACM::Model::ExtendedKeyUsageName::NONE: name = "None"; break; case Aws::ACM::Model::ExtendedKeyUsageName::NOT_SET: name = "Not set"; break; case Aws::ACM::Model::ExtendedKeyUsageName::OCSP_SIGNING: name = "OCSP signing"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TIME_STAMPING: name = "Time stamping"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TLS_WEB_CLIENT_AUTHENTICATION: name = "TLS web client authentication"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TLS_WEB_SERVER_AUTHENTICATION: name = "TLS web server authentication"; break; default: name = "Cannot determine"; } std::cout << " Name: " << name << std::endl; std::cout << " OID: " << usage.GetOID() << std::endl << std::endl; } std::cout << std::endl; } Aws::ACM::Model::CertificateStatus certificateStatus = certificate.GetStatus(); Aws::String status; switch (certificateStatus) { case Aws::ACM::Model::CertificateStatus::EXPIRED: status = "Expired"; break; case Aws::ACM::Model::CertificateStatus::FAILED: status = "Failed"; break; case Aws::ACM::Model::CertificateStatus::INACTIVE: status = "Inactive"; break; case Aws::ACM::Model::CertificateStatus::ISSUED: status = "Issued"; break; case Aws::ACM::Model::CertificateStatus::NOT_SET: status = "Not set"; break; case Aws::ACM::Model::CertificateStatus::PENDING_VALIDATION: status = "Pending validation"; break; case Aws::ACM::Model::CertificateStatus::REVOKED: status = "Revoked"; break; case Aws::ACM::Model::CertificateStatus::VALIDATION_TIMED_OUT: status = "Validation timed out"; break; default: status = "Cannot determine"; } std::cout << "Status: " << status << std::endl; if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::FAILED) { Aws::ACM::Model::FailureReason failureReason = certificate.GetFailureReason(); Aws::String reason; switch (failureReason) { case Aws::ACM::Model::FailureReason::ADDITIONAL_VERIFICATION_REQUIRED: reason = "Additional verification required"; break; case Aws::ACM::Model::FailureReason::CAA_ERROR: reason = "CAA error"; break; case Aws::ACM::Model::FailureReason::DOMAIN_NOT_ALLOWED: reason = "Domain not allowed"; break; case Aws::ACM::Model::FailureReason::DOMAIN_VALIDATION_DENIED: reason = "Domain validation denied"; break; case Aws::ACM::Model::FailureReason::INVALID_PUBLIC_DOMAIN: reason = "Invalid public domain"; break; case Aws::ACM::Model::FailureReason::NOT_SET: reason = "Not set"; break; case Aws::ACM::Model::FailureReason::NO_AVAILABLE_CONTACTS: reason = "No available contacts"; break; case Aws::ACM::Model::FailureReason::OTHER: reason = "Other"; break; case Aws::ACM::Model::FailureReason::PCA_ACCESS_DENIED: reason = "PCA access denied"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_ARGS: reason = "PCA invalid args"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_ARN: reason = "PCA invalid ARN"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_DURATION: reason = "PCA invalid duration"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_STATE: reason = "PCA invalid state"; break; case Aws::ACM::Model::FailureReason::PCA_LIMIT_EXCEEDED: reason = "PCA limit exceeded"; break; case Aws::ACM::Model::FailureReason::PCA_NAME_CONSTRAINTS_VALIDATION: reason = "PCA name constraints validation"; break; case Aws::ACM::Model::FailureReason::PCA_REQUEST_FAILED: reason = "PCA request failed"; break; case Aws::ACM::Model::FailureReason::PCA_RESOURCE_NOT_FOUND: reason = "PCA resource not found"; break; default: reason = "Cannot determine"; } std::cout << "Failure reason: " << reason << std::endl; } if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::REVOKED) { std::cout << "Revoked at (GMT): " << certificate.GetRevokedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; Aws::ACM::Model::RevocationReason revocationReason = certificate.GetRevocationReason(); Aws::String reason; switch (revocationReason) { case Aws::ACM::Model::RevocationReason::AFFILIATION_CHANGED: reason = "Affiliation changed"; break; case Aws::ACM::Model::RevocationReason::A_A_COMPROMISE: reason = "AA compromise"; break; case Aws::ACM::Model::RevocationReason::CA_COMPROMISE: reason = "CA compromise"; break; case Aws::ACM::Model::RevocationReason::CERTIFICATE_HOLD: reason = "Certificate hold"; break; case Aws::ACM::Model::RevocationReason::CESSATION_OF_OPERATION: reason = "Cessation of operation"; break; case Aws::ACM::Model::RevocationReason::KEY_COMPROMISE: reason = "Key compromise"; break; case Aws::ACM::Model::RevocationReason::NOT_SET: reason = "Not set"; break; case Aws::ACM::Model::RevocationReason::PRIVILEGE_WITHDRAWN: reason = "Privilege withdrawn"; break; case Aws::ACM::Model::RevocationReason::REMOVE_FROM_CRL: reason = "Revoke from CRL"; break; case Aws::ACM::Model::RevocationReason::SUPERCEDED: reason = "Superceded"; break; case Aws::ACM::Model::RevocationReason::UNSPECIFIED: reason = "Unspecified"; break; default: reason = "Cannot determine"; } std::cout << "Revocation reason: " << reason << std::endl; } if (certificate.GetType() == Aws::ACM::Model::CertificateType::IMPORTED) { std::cout << "Imported at (GMT): " << certificate.GetImportedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } Aws::Vector<Aws::String> inUseBys = certificate.GetInUseBy(); if (!inUseBys.empty()) { std::cout << std::endl << "In use by:" << std::endl << std::endl; for (auto &in_use_by: inUseBys) { std::cout << " " << in_use_by << std::endl; } std::cout << std::endl; } if (certificate.GetType() == Aws::ACM::Model::CertificateType::AMAZON_ISSUED && certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::ISSUED) { std::cout << "Issued at (GMT): " << certificate.GetIssuedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } std::cout << "Issuer: " << certificate.GetIssuer() << std::endl; Aws::ACM::Model::KeyAlgorithm keyAlgorithm = certificate.GetKeyAlgorithm(); Aws::String algorithm; switch (keyAlgorithm) { case Aws::ACM::Model::KeyAlgorithm::EC_prime256v1: algorithm = "P-256 (secp256r1, prime256v1)"; break; case Aws::ACM::Model::KeyAlgorithm::EC_secp384r1: algorithm = "P-384 (secp384r1)"; break; case Aws::ACM::Model::KeyAlgorithm::EC_secp521r1: algorithm = "P-521 (secp521r1)"; break; case Aws::ACM::Model::KeyAlgorithm::NOT_SET: algorithm = "Not set"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_1024: algorithm = "RSA 1024"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_2048: algorithm = "RSA 2048"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_4096: algorithm = "RSA 4096"; break; default: algorithm = "Cannot determine"; } std::cout << "Key algorithm: " << algorithm << std::endl; if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::ISSUED) { std::cout << "Not valid after (GMT): " << certificate.GetNotAfter().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; std::cout << "Not valid before (GMT): " << certificate.GetNotBefore().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } Aws::ACM::Model::CertificateTransparencyLoggingPreference loggingPreference = certificate.GetOptions().GetCertificateTransparencyLoggingPreference(); Aws::String preference; switch (loggingPreference) { case Aws::ACM::Model::CertificateTransparencyLoggingPreference::DISABLED: preference = "Disabled"; break; case Aws::ACM::Model::CertificateTransparencyLoggingPreference::ENABLED: preference = "Enabled"; break; case Aws::ACM::Model::CertificateTransparencyLoggingPreference::NOT_SET: preference = "Not set"; break; default: preference = "Cannot determine"; } std::cout << "Logging preference: " << preference << std::endl; std::cout << "Serial: " << certificate.GetSerial() << std::endl; std::cout << "Signature algorithm: " << certificate.GetSignatureAlgorithm() << std::endl; std::cout << "Subject: " << certificate.GetSubject() << std::endl; Aws::ACM::Model::CertificateType certificateType = certificate.GetType(); Aws::String type; switch (certificateType) { case Aws::ACM::Model::CertificateType::AMAZON_ISSUED: type = "Amazon issued"; break; case Aws::ACM::Model::CertificateType::IMPORTED: type = "Imported"; break; case Aws::ACM::Model::CertificateType::NOT_SET: type = "Not set"; break; case Aws::ACM::Model::CertificateType::PRIVATE_: type = "Private"; break; default: type = "Cannot determine"; } std::cout << "Type: " << type << std::endl; Aws::Vector<Aws::String> altNames = certificate.GetSubjectAlternativeNames(); if (!altNames.empty()) { std::cout << std::endl << "Alternative names:" << std::endl << std::endl; for (auto &alt_name: altNames) { std::cout << " " << alt_name << std::endl; } std::cout << std::endl; } } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta DescribeCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar DescribeCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Describe an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::describeCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::DescribeCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::DescribeCertificateOutcome outcome = acm_client.DescribeCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: DescribeCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { Aws::ACM::Model::CertificateDetail certificate = outcome.GetResult().GetCertificate(); std::cout << "Success: Information about certificate " "with ARN '" << certificateArn << "':" << std::endl << std::endl; std::cout << "ARN: " << certificate.GetCertificateArn() << std::endl; std::cout << "Authority ARN: " << certificate.GetCertificateAuthorityArn() << std::endl; std::cout << "Created at (GMT): " << certificate.GetCreatedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; std::cout << "Domain name: " << certificate.GetDomainName() << std::endl; Aws::Vector<Aws::ACM::Model::DomainValidation> options = certificate.GetDomainValidationOptions(); if (!options.empty()) { std::cout << std::endl << "Domain validation information: " << std::endl << std::endl; for (auto &validation: options) { std::cout << " Domain name: " << validation.GetDomainName() << std::endl; const Aws::ACM::Model::ResourceRecord &record = validation.GetResourceRecord(); std::cout << " Resource record name: " << record.GetName() << std::endl; Aws::ACM::Model::RecordType recordType = record.GetType(); Aws::String type; switch (recordType) { case Aws::ACM::Model::RecordType::CNAME: type = "CNAME"; break; case Aws::ACM::Model::RecordType::NOT_SET: type = "Not set"; break; default: type = "Cannot determine."; break; } std::cout << " Resource record type: " << type << std::endl; std::cout << " Resource record value: " << record.GetValue() << std::endl; std::cout << " Validation domain: " << validation.GetValidationDomain() << std::endl; Aws::Vector<Aws::String> emails = validation.GetValidationEmails(); if (!emails.empty()) { std::cout << " Validation emails:" << std::endl << std::endl; for (auto &email: emails) { std::cout << " " << email << std::endl; } std::cout << std::endl; } Aws::ACM::Model::ValidationMethod validationMethod = validation.GetValidationMethod(); Aws::String method; switch (validationMethod) { case Aws::ACM::Model::ValidationMethod::DNS: method = "DNS"; break; case Aws::ACM::Model::ValidationMethod::EMAIL: method = "Email"; break; case Aws::ACM::Model::ValidationMethod::NOT_SET: method = "Not set"; break; default: method = "Cannot determine"; } std::cout << " Validation method: " << method << std::endl; Aws::ACM::Model::DomainStatus domainStatus = validation.GetValidationStatus(); Aws::String status; switch (domainStatus) { case Aws::ACM::Model::DomainStatus::FAILED: status = "Failed"; break; case Aws::ACM::Model::DomainStatus::NOT_SET: status = "Not set"; break; case Aws::ACM::Model::DomainStatus::PENDING_VALIDATION: status = "Pending validation"; break; case Aws::ACM::Model::DomainStatus::SUCCESS: status = "Success"; break; default: status = "Cannot determine"; } std::cout << " Domain validation status: " << status << std::endl << std::endl; } } Aws::Vector<Aws::ACM::Model::ExtendedKeyUsage> usages = certificate.GetExtendedKeyUsages(); if (!usages.empty()) { std::cout << std::endl << "Extended key usages:" << std::endl << std::endl; for (auto &usage: usages) { Aws::ACM::Model::ExtendedKeyUsageName usageName = usage.GetName(); Aws::String name; switch (usageName) { case Aws::ACM::Model::ExtendedKeyUsageName::ANY: name = "Any"; break; case Aws::ACM::Model::ExtendedKeyUsageName::CODE_SIGNING: name = "Code signing"; break; case Aws::ACM::Model::ExtendedKeyUsageName::CUSTOM: name = "Custom"; break; case Aws::ACM::Model::ExtendedKeyUsageName::EMAIL_PROTECTION: name = "Email protection"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_END_SYSTEM: name = "IPSEC end system"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_TUNNEL: name = "IPSEC tunnel"; break; case Aws::ACM::Model::ExtendedKeyUsageName::IPSEC_USER: name = "IPSEC user"; break; case Aws::ACM::Model::ExtendedKeyUsageName::NONE: name = "None"; break; case Aws::ACM::Model::ExtendedKeyUsageName::NOT_SET: name = "Not set"; break; case Aws::ACM::Model::ExtendedKeyUsageName::OCSP_SIGNING: name = "OCSP signing"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TIME_STAMPING: name = "Time stamping"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TLS_WEB_CLIENT_AUTHENTICATION: name = "TLS web client authentication"; break; case Aws::ACM::Model::ExtendedKeyUsageName::TLS_WEB_SERVER_AUTHENTICATION: name = "TLS web server authentication"; break; default: name = "Cannot determine"; } std::cout << " Name: " << name << std::endl; std::cout << " OID: " << usage.GetOID() << std::endl << std::endl; } std::cout << std::endl; } Aws::ACM::Model::CertificateStatus certificateStatus = certificate.GetStatus(); Aws::String status; switch (certificateStatus) { case Aws::ACM::Model::CertificateStatus::EXPIRED: status = "Expired"; break; case Aws::ACM::Model::CertificateStatus::FAILED: status = "Failed"; break; case Aws::ACM::Model::CertificateStatus::INACTIVE: status = "Inactive"; break; case Aws::ACM::Model::CertificateStatus::ISSUED: status = "Issued"; break; case Aws::ACM::Model::CertificateStatus::NOT_SET: status = "Not set"; break; case Aws::ACM::Model::CertificateStatus::PENDING_VALIDATION: status = "Pending validation"; break; case Aws::ACM::Model::CertificateStatus::REVOKED: status = "Revoked"; break; case Aws::ACM::Model::CertificateStatus::VALIDATION_TIMED_OUT: status = "Validation timed out"; break; default: status = "Cannot determine"; } std::cout << "Status: " << status << std::endl; if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::FAILED) { Aws::ACM::Model::FailureReason failureReason = certificate.GetFailureReason(); Aws::String reason; switch (failureReason) { case Aws::ACM::Model::FailureReason::ADDITIONAL_VERIFICATION_REQUIRED: reason = "Additional verification required"; break; case Aws::ACM::Model::FailureReason::CAA_ERROR: reason = "CAA error"; break; case Aws::ACM::Model::FailureReason::DOMAIN_NOT_ALLOWED: reason = "Domain not allowed"; break; case Aws::ACM::Model::FailureReason::DOMAIN_VALIDATION_DENIED: reason = "Domain validation denied"; break; case Aws::ACM::Model::FailureReason::INVALID_PUBLIC_DOMAIN: reason = "Invalid public domain"; break; case Aws::ACM::Model::FailureReason::NOT_SET: reason = "Not set"; break; case Aws::ACM::Model::FailureReason::NO_AVAILABLE_CONTACTS: reason = "No available contacts"; break; case Aws::ACM::Model::FailureReason::OTHER: reason = "Other"; break; case Aws::ACM::Model::FailureReason::PCA_ACCESS_DENIED: reason = "PCA access denied"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_ARGS: reason = "PCA invalid args"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_ARN: reason = "PCA invalid ARN"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_DURATION: reason = "PCA invalid duration"; break; case Aws::ACM::Model::FailureReason::PCA_INVALID_STATE: reason = "PCA invalid state"; break; case Aws::ACM::Model::FailureReason::PCA_LIMIT_EXCEEDED: reason = "PCA limit exceeded"; break; case Aws::ACM::Model::FailureReason::PCA_NAME_CONSTRAINTS_VALIDATION: reason = "PCA name constraints validation"; break; case Aws::ACM::Model::FailureReason::PCA_REQUEST_FAILED: reason = "PCA request failed"; break; case Aws::ACM::Model::FailureReason::PCA_RESOURCE_NOT_FOUND: reason = "PCA resource not found"; break; default: reason = "Cannot determine"; } std::cout << "Failure reason: " << reason << std::endl; } if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::REVOKED) { std::cout << "Revoked at (GMT): " << certificate.GetRevokedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; Aws::ACM::Model::RevocationReason revocationReason = certificate.GetRevocationReason(); Aws::String reason; switch (revocationReason) { case Aws::ACM::Model::RevocationReason::AFFILIATION_CHANGED: reason = "Affiliation changed"; break; case Aws::ACM::Model::RevocationReason::A_A_COMPROMISE: reason = "AA compromise"; break; case Aws::ACM::Model::RevocationReason::CA_COMPROMISE: reason = "CA compromise"; break; case Aws::ACM::Model::RevocationReason::CERTIFICATE_HOLD: reason = "Certificate hold"; break; case Aws::ACM::Model::RevocationReason::CESSATION_OF_OPERATION: reason = "Cessation of operation"; break; case Aws::ACM::Model::RevocationReason::KEY_COMPROMISE: reason = "Key compromise"; break; case Aws::ACM::Model::RevocationReason::NOT_SET: reason = "Not set"; break; case Aws::ACM::Model::RevocationReason::PRIVILEGE_WITHDRAWN: reason = "Privilege withdrawn"; break; case Aws::ACM::Model::RevocationReason::REMOVE_FROM_CRL: reason = "Revoke from CRL"; break; case Aws::ACM::Model::RevocationReason::SUPERCEDED: reason = "Superceded"; break; case Aws::ACM::Model::RevocationReason::UNSPECIFIED: reason = "Unspecified"; break; default: reason = "Cannot determine"; } std::cout << "Revocation reason: " << reason << std::endl; } if (certificate.GetType() == Aws::ACM::Model::CertificateType::IMPORTED) { std::cout << "Imported at (GMT): " << certificate.GetImportedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } Aws::Vector<Aws::String> inUseBys = certificate.GetInUseBy(); if (!inUseBys.empty()) { std::cout << std::endl << "In use by:" << std::endl << std::endl; for (auto &in_use_by: inUseBys) { std::cout << " " << in_use_by << std::endl; } std::cout << std::endl; } if (certificate.GetType() == Aws::ACM::Model::CertificateType::AMAZON_ISSUED && certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::ISSUED) { std::cout << "Issued at (GMT): " << certificate.GetIssuedAt().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } std::cout << "Issuer: " << certificate.GetIssuer() << std::endl; Aws::ACM::Model::KeyAlgorithm keyAlgorithm = certificate.GetKeyAlgorithm(); Aws::String algorithm; switch (keyAlgorithm) { case Aws::ACM::Model::KeyAlgorithm::EC_prime256v1: algorithm = "P-256 (secp256r1, prime256v1)"; break; case Aws::ACM::Model::KeyAlgorithm::EC_secp384r1: algorithm = "P-384 (secp384r1)"; break; case Aws::ACM::Model::KeyAlgorithm::EC_secp521r1: algorithm = "P-521 (secp521r1)"; break; case Aws::ACM::Model::KeyAlgorithm::NOT_SET: algorithm = "Not set"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_1024: algorithm = "RSA 1024"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_2048: algorithm = "RSA 2048"; break; case Aws::ACM::Model::KeyAlgorithm::RSA_4096: algorithm = "RSA 4096"; break; default: algorithm = "Cannot determine"; } std::cout << "Key algorithm: " << algorithm << std::endl; if (certificate.GetStatus() == Aws::ACM::Model::CertificateStatus::ISSUED) { std::cout << "Not valid after (GMT): " << certificate.GetNotAfter().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; std::cout << "Not valid before (GMT): " << certificate.GetNotBefore().ToGmtString( Aws::Utils::DateFormat::ISO_8601) << std::endl; } Aws::ACM::Model::CertificateTransparencyLoggingPreference loggingPreference = certificate.GetOptions().GetCertificateTransparencyLoggingPreference(); Aws::String preference; switch (loggingPreference) { case Aws::ACM::Model::CertificateTransparencyLoggingPreference::DISABLED: preference = "Disabled"; break; case Aws::ACM::Model::CertificateTransparencyLoggingPreference::ENABLED: preference = "Enabled"; break; case Aws::ACM::Model::CertificateTransparencyLoggingPreference::NOT_SET: preference = "Not set"; break; default: preference = "Cannot determine"; } std::cout << "Logging preference: " << preference << std::endl; std::cout << "Serial: " << certificate.GetSerial() << std::endl; std::cout << "Signature algorithm: " << certificate.GetSignatureAlgorithm() << std::endl; std::cout << "Subject: " << certificate.GetSubject() << std::endl; Aws::ACM::Model::CertificateType certificateType = certificate.GetType(); Aws::String type; switch (certificateType) { case Aws::ACM::Model::CertificateType::AMAZON_ISSUED: type = "Amazon issued"; break; case Aws::ACM::Model::CertificateType::IMPORTED: type = "Imported"; break; case Aws::ACM::Model::CertificateType::NOT_SET: type = "Not set"; break; case Aws::ACM::Model::CertificateType::PRIVATE_: type = "Private"; break; default: type = "Cannot determine"; } std::cout << "Type: " << type << std::endl; Aws::Vector<Aws::String> altNames = certificate.GetSubjectAlternativeNames(); if (!altNames.empty()) { std::cout << std::endl << "Alternative names:" << std::endl << std::endl; for (auto &alt_name: altNames) { std::cout << " " << alt_name << std::endl; } std::cout << std::endl; } } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta DescribeCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ExportCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de 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(); }
  • Para obtener más información sobre la API, consulta ExportCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ExportCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de 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(); }
  • Para obtener más información sobre la API, consulta ExportCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar GetCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Get an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::getCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::GetCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::GetCertificateOutcome outcome = acmClient.GetCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: GetCertificate: " << 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::cout << "Certificate chain: " << std::endl << std::endl << result.GetCertificateChain() << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta GetCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar GetCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Get an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::getCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::GetCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::GetCertificateOutcome outcome = acmClient.GetCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: GetCertificate: " << 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::cout << "Certificate chain: " << std::endl << std::endl << result.GetCertificateChain() << std::endl; } return outcome.IsSuccess(); }
  • Para obtener más información sobre la API, consulta GetCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ImportCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Import an AWS Certificate Manager (ACM) certificate. /*! \param certificateFile: Path to certificate to import. \param privateKeyFile: Path to file containing a private key. \param certificateChainFile: Path to file containing a PEM encoded certificate chain. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::importCertificate(const Aws::String &certificateFile, const Aws::String &privateKeyFile, const Aws::String &certificateChainFile, const Aws::Client::ClientConfiguration &clientConfiguration) { std::ifstream certificateInStream(certificateFile.c_str()); if (!certificateInStream) { std::cerr << "Error: The certificate file '" << certificateFile << "' does not exist." << std::endl; return false; } std::ifstream privateKeyInstream(privateKeyFile.c_str()); if (!privateKeyInstream) { std::cerr << "Error: The private key file '" << privateKeyFile << "' does not exist." << std::endl; return false; } std::ifstream certificateChainInStream(certificateChainFile.c_str()); if (!certificateChainInStream) { std::cerr << "Error: The certificate chain file '" << certificateChainFile << "' does not exist." << std::endl; return false; } Aws::String certificate; certificate.assign(std::istreambuf_iterator<char>(certificateInStream), std::istreambuf_iterator<char>()); Aws::String privateKey; privateKey.assign(std::istreambuf_iterator<char>(privateKeyInstream), std::istreambuf_iterator<char>()); Aws::String certificateChain; certificateChain.assign(std::istreambuf_iterator<char>(certificateChainInStream), std::istreambuf_iterator<char>()); Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ImportCertificateRequest request; request.WithCertificate(Aws::Utils::ByteBuffer((unsigned char *) certificate.c_str(), certificate.size())) .WithPrivateKey(Aws::Utils::ByteBuffer((unsigned char *) privateKey.c_str(), privateKey.size())) .WithCertificateChain(Aws::Utils::ByteBuffer((unsigned char *) certificateChain.c_str(), certificateChain.size())); Aws::ACM::Model::ImportCertificateOutcome outcome = acmClient.ImportCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ImportCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Certificate associated with ARN '" << outcome.GetResult().GetCertificateArn() << "' imported." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta ImportCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ImportCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Import an AWS Certificate Manager (ACM) certificate. /*! \param certificateFile: Path to certificate to import. \param privateKeyFile: Path to file containing a private key. \param certificateChainFile: Path to file containing a PEM encoded certificate chain. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::importCertificate(const Aws::String &certificateFile, const Aws::String &privateKeyFile, const Aws::String &certificateChainFile, const Aws::Client::ClientConfiguration &clientConfiguration) { std::ifstream certificateInStream(certificateFile.c_str()); if (!certificateInStream) { std::cerr << "Error: The certificate file '" << certificateFile << "' does not exist." << std::endl; return false; } std::ifstream privateKeyInstream(privateKeyFile.c_str()); if (!privateKeyInstream) { std::cerr << "Error: The private key file '" << privateKeyFile << "' does not exist." << std::endl; return false; } std::ifstream certificateChainInStream(certificateChainFile.c_str()); if (!certificateChainInStream) { std::cerr << "Error: The certificate chain file '" << certificateChainFile << "' does not exist." << std::endl; return false; } Aws::String certificate; certificate.assign(std::istreambuf_iterator<char>(certificateInStream), std::istreambuf_iterator<char>()); Aws::String privateKey; privateKey.assign(std::istreambuf_iterator<char>(privateKeyInstream), std::istreambuf_iterator<char>()); Aws::String certificateChain; certificateChain.assign(std::istreambuf_iterator<char>(certificateChainInStream), std::istreambuf_iterator<char>()); Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ImportCertificateRequest request; request.WithCertificate(Aws::Utils::ByteBuffer((unsigned char *) certificate.c_str(), certificate.size())) .WithPrivateKey(Aws::Utils::ByteBuffer((unsigned char *) privateKey.c_str(), privateKey.size())) .WithCertificateChain(Aws::Utils::ByteBuffer((unsigned char *) certificateChain.c_str(), certificateChain.size())); Aws::ACM::Model::ImportCertificateOutcome outcome = acmClient.ImportCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ImportCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Certificate associated with ARN '" << outcome.GetResult().GetCertificateArn() << "' imported." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta ImportCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ListCertificates.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! List the AWS Certificate Manager (ACM) certificates in an account. /*! \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::listCertificates( const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ListCertificatesRequest request; Aws::Vector<Aws::ACM::Model::CertificateSummary> allCertificates; Aws::String nextToken; do { if (!nextToken.empty()) { request.SetNextToken(nextToken); } Aws::ACM::Model::ListCertificatesOutcome outcome = acmClient.ListCertificates(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ListCertificates: " << outcome.GetError().GetMessage() << std::endl; return false; } else { const Aws::ACM::Model::ListCertificatesResult &result = outcome.GetResult(); const Aws::Vector<Aws::ACM::Model::CertificateSummary> &certificates = result.GetCertificateSummaryList(); allCertificates.insert(allCertificates.end(), certificates.begin(), certificates.end()); nextToken = result.GetNextToken(); } } while (!nextToken.empty()); if (!allCertificates.empty()) { for (const Aws::ACM::Model::CertificateSummary &certificate: allCertificates) { std::cout << "Certificate ARN: " << certificate.GetCertificateArn() << std::endl; std::cout << "Domain name: " << certificate.GetDomainName() << std::endl << std::endl; } } else { std::cout << "No available certificates found in account." << std::endl; } return true; }
  • Para obtener más información sobre la API, consulta ListCertificatesla Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ListCertificates.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! List the AWS Certificate Manager (ACM) certificates in an account. /*! \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::listCertificates( const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ListCertificatesRequest request; Aws::Vector<Aws::ACM::Model::CertificateSummary> allCertificates; Aws::String nextToken; do { if (!nextToken.empty()) { request.SetNextToken(nextToken); } Aws::ACM::Model::ListCertificatesOutcome outcome = acmClient.ListCertificates(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ListCertificates: " << outcome.GetError().GetMessage() << std::endl; return false; } else { const Aws::ACM::Model::ListCertificatesResult &result = outcome.GetResult(); const Aws::Vector<Aws::ACM::Model::CertificateSummary> &certificates = result.GetCertificateSummaryList(); allCertificates.insert(allCertificates.end(), certificates.begin(), certificates.end()); nextToken = result.GetNextToken(); } } while (!nextToken.empty()); if (!allCertificates.empty()) { for (const Aws::ACM::Model::CertificateSummary &certificate: allCertificates) { std::cout << "Certificate ARN: " << certificate.GetCertificateArn() << std::endl; std::cout << "Domain name: " << certificate.GetDomainName() << std::endl << std::endl; } } else { std::cout << "No available certificates found in account." << std::endl; } return true; }
  • Para obtener más información sobre la API, consulta ListCertificatesla Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ListTagsForCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! List the tags for an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::listTagsForCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::ListTagsForCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::ListTagsForCertificateOutcome outcome = acm_client.ListTagsForCertificate(request); if (!outcome.IsSuccess()) { std::cout << "Error: ListTagsForCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Information about tags for " "certificate with ARN '" << certificateArn << "':" << std::endl << std::endl; auto result = outcome.GetResult(); Aws::Vector<Aws::ACM::Model::Tag> tags = result.GetTags(); if (tags.size() > 0) { for (const Aws::ACM::Model::Tag &tag: tags) { std::cout << "Key: " << tag.GetKey() << std::endl; std::cout << "Value: " << tag.GetValue() << std::endl << std::endl; } } else { std::cout << "No tags found." << std::endl; } return true; } }
  • Para obtener más información sobre la API, consulta ListTagsForCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ListTagsForCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! List the tags for an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::listTagsForCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::ListTagsForCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::ListTagsForCertificateOutcome outcome = acm_client.ListTagsForCertificate(request); if (!outcome.IsSuccess()) { std::cout << "Error: ListTagsForCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Information about tags for " "certificate with ARN '" << certificateArn << "':" << std::endl << std::endl; auto result = outcome.GetResult(); Aws::Vector<Aws::ACM::Model::Tag> tags = result.GetTags(); if (tags.size() > 0) { for (const Aws::ACM::Model::Tag &tag: tags) { std::cout << "Key: " << tag.GetKey() << std::endl; std::cout << "Value: " << tag.GetValue() << std::endl << std::endl; } } else { std::cout << "No tags found." << std::endl; } return true; } }
  • Para obtener más información sobre la API, consulta ListTagsForCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar RemoveTagsFromCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Remove a tag from an ACM certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::removeTagsFromCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.SetKey(tagKey); tags.push_back(tag); Aws::ACM::Model::RemoveTagsFromCertificateRequest request; request.WithCertificateArn(certificateArn) .WithTags(tags); Aws::ACM::Model::RemoveTagsFromCertificateOutcome outcome = acmClient.RemoveTagsFromCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RemoveTagFromCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Tag with key '" << tagKey << "' removed from " << "certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }

En el siguiente ejemplo de código, se muestra cómo utilizar RemoveTagsFromCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Remove a tag from an ACM certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::removeTagsFromCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.SetKey(tagKey); tags.push_back(tag); Aws::ACM::Model::RemoveTagsFromCertificateRequest request; request.WithCertificateArn(certificateArn) .WithTags(tags); Aws::ACM::Model::RemoveTagsFromCertificateOutcome outcome = acmClient.RemoveTagsFromCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RemoveTagFromCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Tag with key '" << tagKey << "' removed from " << "certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }

En el siguiente ejemplo de código, se muestra cómo utilizar RenewCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Renew an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::renewCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::RenewCertificateRequest request; request.SetCertificateArn(certificateArn); Aws::ACM::Model::RenewCertificateOutcome outcome = acmClient.RenewCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RenewCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Renewed certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta RenewCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar RenewCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Renew an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::renewCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::RenewCertificateRequest request; request.SetCertificateArn(certificateArn); Aws::ACM::Model::RenewCertificateOutcome outcome = acmClient.RenewCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RenewCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Renewed certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta RenewCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar RequestCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Request an AWS Certificate Manager (ACM) certificate. /*! \param domainName: A fully qualified domain name. \param idempotencyToken: Customer chosen string for idempotency. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::requestCertificate(const Aws::String &domainName, const Aws::String &idempotencyToken, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::RequestCertificateRequest request; request.WithDomainName(domainName) .WithIdempotencyToken(idempotencyToken); Aws::ACM::Model::RequestCertificateOutcome outcome = acmClient.RequestCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "RequestCertificate error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The newly requested certificate's " "ARN is '" << outcome.GetResult().GetCertificateArn() << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta RequestCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar RequestCertificate.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Request an AWS Certificate Manager (ACM) certificate. /*! \param domainName: A fully qualified domain name. \param idempotencyToken: Customer chosen string for idempotency. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::requestCertificate(const Aws::String &domainName, const Aws::String &idempotencyToken, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::RequestCertificateRequest request; request.WithDomainName(domainName) .WithIdempotencyToken(idempotencyToken); Aws::ACM::Model::RequestCertificateOutcome outcome = acmClient.RequestCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "RequestCertificate error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The newly requested certificate's " "ARN is '" << outcome.GetResult().GetCertificateArn() << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta RequestCertificatela Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ResendValidationEmail.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Resend the email that requests domain ownership validation. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param domainName: A fully qualified domain name. \param validationDomain: The base validation domain that will act as the suffix of the email addresses. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::resendValidationEmail(const Aws::String &certificateArn, const Aws::String &domainName, const Aws::String &validationDomain, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ResendValidationEmailRequest request; request.WithCertificateArn(certificateArn) .WithDomain(domainName) .WithValidationDomain(validationDomain); Aws::ACM::Model::ResendValidationEmailOutcome outcome = acmClient.ResendValidationEmail(request); if (!outcome.IsSuccess()) { std::cerr << "ResendValidationEmail error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The validation email has been resent." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta ResendValidationEmailla Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar ResendValidationEmail.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Resend the email that requests domain ownership validation. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param domainName: A fully qualified domain name. \param validationDomain: The base validation domain that will act as the suffix of the email addresses. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::resendValidationEmail(const Aws::String &certificateArn, const Aws::String &domainName, const Aws::String &validationDomain, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ResendValidationEmailRequest request; request.WithCertificateArn(certificateArn) .WithDomain(domainName) .WithValidationDomain(validationDomain); Aws::ACM::Model::ResendValidationEmailOutcome outcome = acmClient.ResendValidationEmail(request); if (!outcome.IsSuccess()) { std::cerr << "ResendValidationEmail error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The validation email has been resent." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta ResendValidationEmailla Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar UpdateCertificateOptions.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Update an AWS Certificate Manager (ACM) certificate option. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param loggingEnabled: Boolean specifying logging enabled. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::updateCertificateOption(const Aws::String &certificateArn, bool loggingEnabled, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::UpdateCertificateOptionsRequest request; request.SetCertificateArn(certificateArn); Aws::ACM::Model::CertificateOptions options; if (loggingEnabled) { options.SetCertificateTransparencyLoggingPreference( Aws::ACM::Model::CertificateTransparencyLoggingPreference::ENABLED); } else { options.SetCertificateTransparencyLoggingPreference( Aws::ACM::Model::CertificateTransparencyLoggingPreference::DISABLED); } request.SetOptions(options); Aws::ACM::Model::UpdateCertificateOptionsOutcome outcome = acmClient.UpdateCertificateOptions(request); if (!outcome.IsSuccess()) { std::cerr << "UpdateCertificateOption error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The option '" << (loggingEnabled ? "enabled" : "disabled") << "' has been set for " "the certificate with the ARN '" << certificateArn << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta UpdateCertificateOptionsla Referencia AWS SDK for C++ de la API.

En el siguiente ejemplo de código, se muestra cómo utilizar UpdateCertificateOptions.

SDK para C++
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS.

//! Update an AWS Certificate Manager (ACM) certificate option. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param loggingEnabled: Boolean specifying logging enabled. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::updateCertificateOption(const Aws::String &certificateArn, bool loggingEnabled, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::UpdateCertificateOptionsRequest request; request.SetCertificateArn(certificateArn); Aws::ACM::Model::CertificateOptions options; if (loggingEnabled) { options.SetCertificateTransparencyLoggingPreference( Aws::ACM::Model::CertificateTransparencyLoggingPreference::ENABLED); } else { options.SetCertificateTransparencyLoggingPreference( Aws::ACM::Model::CertificateTransparencyLoggingPreference::DISABLED); } request.SetOptions(options); Aws::ACM::Model::UpdateCertificateOptionsOutcome outcome = acmClient.UpdateCertificateOptions(request); if (!outcome.IsSuccess()) { std::cerr << "UpdateCertificateOption error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The option '" << (loggingEnabled ? "enabled" : "disabled") << "' has been set for " "the certificate with the ARN '" << certificateArn << "'." << std::endl; return true; } }
  • Para obtener más información sobre la API, consulta UpdateCertificateOptionsla Referencia AWS SDK for C++ de la API.

PrivacidadTérminos del sitioPreferencias de cookies
© 2025, Amazon Web Services, Inc o sus afiliados. Todos los derechos reservados.