Skip to content

import_certificate async

import_certificate(
    certificate: CertificateBodyBlob,
    private_key: PrivateKeyBlob,
    *,
    config_overrides: Optional[AsyncACMClientConfig] = None,
    certificate_arn: Optional[Arn] = None,
    certificate_chain: Optional[CertificateChainBlob] = None,
    tags: Optional[TagList] = None,
) -> ImportCertificateResponse

Imports a certificate into Certificate Manager (ACM) to use with services that are integrated with ACM. Note that integrated services allow only certificate types and keys they support to be associated with their resources. Further, their support differs depending on whether the certificate is imported into IAM or into ACM. For more information, see the documentation for each service. For more information about importing certificates into ACM, see Importing Certificates in the Certificate Manager User Guide.

ACM does not provide managed renewal for certificates that you import.

Note the following guidelines when importing third party certificates:

  • You must enter the private key that matches the certificate you are importing.

  • The private key must be unencrypted. You cannot import a private key that is protected by a password or a passphrase.

  • The private key must be no larger than 5 KB (5,120 bytes).

  • The certificate, private key, and certificate chain must be PEM-encoded.

  • The current time must be between the Not Before and Not After certificate fields.

  • The Issuer field must not be empty.

  • The OCSP authority URL, if present, must not exceed 1000 characters.

  • To import a new certificate, omit the CertificateArn argument. Include this argument only when you want to replace a previously imported certificate.

  • When you import a certificate by using the CLI, you must specify the certificate, the certificate chain, and the private key by their file names preceded by fileb://. For example, you can specify a certificate saved in the C:\temp folder as fileb://C:\temp\certificate_to_import.pem. If you are making an HTTP or HTTPS Query request, include these arguments as BLOBs.

  • When you import a certificate by using an SDK, you must specify the certificate, the certificate chain, and the private key files in the manner required by the programming language you're using.

  • The cryptographic algorithm of an imported certificate must match the algorithm of the signing CA. For example, if the signing CA key type is RSA, then the certificate key type must also be RSA.

This operation returns the Amazon Resource Name (ARN) of the imported certificate.

Parameters:

  • certificate_arn (Optional[Arn], default: None ) –

    The Amazon Resource Name (ARN) of an imported certificate to replace. To import a new certificate, omit this field.

  • certificate (CertificateBodyBlob) –

    The certificate to import.

  • private_key (PrivateKeyBlob) –

    The private key that matches the public key in the certificate.

  • certificate_chain (Optional[CertificateChainBlob], default: None ) –

    The PEM encoded certificate chain.

  • tags (Optional[TagList], default: None ) –

    One or more resource tags to associate with the imported certificate.

    Note: You cannot apply tags when reimporting a certificate.

Raises:

  • ConflictException –

    You are trying to update a resource or configuration that is already being created or updated. Wait for the previous operation to finish and try again.

  • InvalidArnException –

    The requested Amazon Resource Name (ARN) does not refer to an existing resource.

  • InvalidParameterException –

    An input parameter was invalid.

  • InvalidTagException –

    One or both of the values that make up the key-value pair is not valid. For example, you cannot specify a tag value that begins with aws:.

  • LimitExceededException –

    An ACM quota has been exceeded.

  • ResourceNotFoundException –

    The specified certificate cannot be found in the caller's account or the caller's account cannot be found.

  • TagPolicyException –

    A specified tag did not comply with an existing tag policy and was rejected.

  • TooManyTagsException –

    The request contains too many tags. Try the request again with fewer tags.

  • ValidationException –

    The supplied input failed to satisfy constraints of an Amazon Web Services service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_acm/_services/async_acm.py
async def import_certificate(
    self,
    certificate: "capo_acm.types.certificate_body_blob.CertificateBodyBlob",
    private_key: "capo_acm.types.private_key_blob.PrivateKeyBlob",
    *,
    config_overrides: Optional[AsyncACMClientConfig] = None,
    certificate_arn: Optional["capo_acm.types.arn.Arn"] = None,
    certificate_chain: Optional[
        "capo_acm.types.certificate_chain_blob.CertificateChainBlob"
    ] = None,
    tags: Optional["capo_acm.types.tag_list.TagList"] = None,
) -> "capo_acm.types.import_certificate_response.ImportCertificateResponse":
    r"""<p>Imports a certificate into Certificate Manager (ACM) to use with services that are integrated with ACM. Note that <a href="https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html">integrated services</a> allow only certificate types and keys they support to be associated with their resources. Further, their support differs depending on whether the certificate is imported into IAM or into ACM. For more information, see the documentation for each service. For more information about importing certificates into ACM, see <a href="https://docs.aws.amazon.com/acm/latest/userguide/import-certificate.html">Importing Certificates</a> in the <i>Certificate Manager User Guide</i>. </p> <note> <p>ACM does not provide <a href="https://docs.aws.amazon.com/acm/latest/userguide/acm-renewal.html">managed renewal</a> for certificates that you import.</p> </note> <p>Note the following guidelines when importing third party certificates:</p> <ul> <li> <p>You must enter the private key that matches the certificate you are importing.</p> </li> <li> <p>The private key must be unencrypted. You cannot import a private key that is protected by a password or a passphrase.</p> </li> <li> <p>The private key must be no larger than 5 KB (5,120 bytes).</p> </li> <li> <p>The certificate, private key, and certificate chain must be PEM-encoded.</p> </li> <li> <p>The current time must be between the <code>Not Before</code> and <code>Not After</code> certificate fields.</p> </li> <li> <p>The <code>Issuer</code> field must not be empty.</p> </li> <li> <p>The OCSP authority URL, if present, must not exceed 1000 characters.</p> </li> <li> <p>To import a new certificate, omit the <code>CertificateArn</code> argument. Include this argument only when you want to replace a previously imported certificate.</p> </li> <li> <p>When you import a certificate by using the CLI, you must specify the certificate, the certificate chain, and the private key by their file names preceded by <code>fileb://</code>. For example, you can specify a certificate saved in the <code>C:\temp</code> folder as <code>fileb://C:\temp\certificate_to_import.pem</code>. If you are making an HTTP or HTTPS Query request, include these arguments as BLOBs. </p> </li> <li> <p>When you import a certificate by using an SDK, you must specify the certificate, the certificate chain, and the private key files in the manner required by the programming language you're using. </p> </li> <li> <p>The cryptographic algorithm of an imported certificate must match the algorithm of the signing CA. For example, if the signing CA key type is RSA, then the certificate key type must also be RSA.</p> </li> </ul> <p>This operation returns the <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a> of the imported certificate.</p>

    Args:
        certificate_arn: <p>The <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a> of an imported certificate to replace. To import a new certificate, omit this field. </p>
        certificate: <p>The certificate to import.</p>
        private_key: <p>The private key that matches the public key in the certificate.</p>
        certificate_chain: <p>The PEM encoded certificate chain.</p>
        tags: <p>One or more resource tags to associate with the imported certificate. </p> <p>Note: You cannot apply tags when reimporting a certificate.</p>

    Raises:
        capo_acm.errors.conflict_exception.ConflictException: <p>You are trying to update a resource or configuration that is already being created or updated. Wait for the previous operation to finish and try again.</p>
        capo_acm.errors.invalid_arn_exception.InvalidArnException: <p>The requested Amazon Resource Name (ARN) does not refer to an existing resource.</p>
        capo_acm.errors.invalid_parameter_exception.InvalidParameterException: <p>An input parameter was invalid.</p>
        capo_acm.errors.invalid_tag_exception.InvalidTagException: <p>One or both of the values that make up the key-value pair is not valid. For example, you cannot specify a tag value that begins with <code>aws:</code>.</p>
        capo_acm.errors.limit_exceeded_exception.LimitExceededException: <p>An ACM quota has been exceeded.</p>
        capo_acm.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified certificate cannot be found in the caller's account or the caller's account cannot be found.</p>
        capo_acm.errors.tag_policy_exception.TagPolicyException: <p>A specified tag did not comply with an existing tag policy and was rejected.</p>
        capo_acm.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains too many tags. Try the request again with fewer tags.</p>
        capo_acm.errors.validation_exception.ValidationException: <p>The supplied input failed to satisfy constraints of an Amazon Web Services service.</p>
        capo_acm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_acm.types.import_certificate_request.ImportCertificateRequest]",
    ) -> AsyncOperationResponse[
        "capo_acm.types.import_certificate_response.ImportCertificateResponse"
    ]:
        import capo_acm._operations.certificate_manager.import_certificate

        (
            output,
            http_response,
        ) = await capo_acm._operations.certificate_manager.import_certificate.async_import_certificate(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_acm.types.import_certificate_request.ImportCertificateRequest",
    ) -> dict[str, Any]:
        import capo_acm.types.import_certificate_request

        return capo_acm.types.import_certificate_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ImportCertificate", redact_input=_redact_input),
    )
    input_: capo_acm.types.import_certificate_request.ImportCertificateRequest = {
        "certificate": certificate,
        "private_key": private_key,
    }
    if certificate_arn is not None:
        input_["certificate_arn"] = certificate_arn
    if certificate_chain is not None:
        input_["certificate_chain"] = certificate_chain
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output