Skip to content

import_certificate async

import_certificate(
    usage: CertificateUsageType,
    certificate: CertificateBodyType,
    *,
    config_overrides: Optional[AsyncTransferClientConfig] = None,
    certificate_chain: Optional[CertificateChainType] = None,
    private_key: Optional[PrivateKeyType] = None,
    active_date: Optional[CertDate] = None,
    inactive_date: Optional[CertDate] = None,
    description: Optional[Description] = None,
    tags: Optional[Tags] = None,
) -> ImportCertificateResponse

Imports the signing and encryption certificates that you need to create local (AS2) profiles and partner profiles.

You can import both the certificate and its chain in the Certificate parameter.

After importing a certificate, Transfer Family automatically creates a Amazon CloudWatch metric called DaysUntilExpiry that tracks the number of days until the certificate expires. The metric is based on the InactiveDate parameter and is published daily in the AWS/Transfer namespace.

It can take up to a full day after importing a certificate for Transfer Family to emit the DaysUntilExpiry metric to your account.

If you use the Certificate parameter to upload both the certificate and its chain, don't use the CertificateChain parameter.

CloudWatch monitoring

The DaysUntilExpiry metric includes the following specifications:

  • Units: Count (days)

  • Dimensions: CertificateId (always present), Description (if provided during certificate import)

  • Statistics: Minimum, Maximum, Average

  • Frequency: Published daily

Parameters:

  • usage (CertificateUsageType) –

    Specifies how this certificate is used. It can be used in the following ways:

    • SIGNING: For signing AS2 messages

    • ENCRYPTION: For encrypting AS2 messages

    • TLS: For securing AS2 communications sent over HTTPS

  • certificate (CertificateBodyType) –
    • For the CLI, provide a file path for a certificate in URI format. For example, --certificate file://encryption-cert.pem. Alternatively, you can provide the raw content.

    • For the SDK, specify the raw content of a certificate file. For example, --certificate "`cat encryption-cert.pem`".

    You can provide both the certificate and its chain in this parameter, without needing to use the CertificateChain parameter. If you use this parameter for both the certificate and its chain, do not use the CertificateChain parameter.

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

    An optional list of certificates that make up the chain for the certificate that's being imported.

  • private_key (Optional[PrivateKeyType], default: None ) –
    • For the CLI, provide a file path for a private key in URI format. For example, --private-key file://encryption-key.pem. Alternatively, you can provide the raw content of the private key file.

    • For the SDK, specify the raw content of a private key file. For example, --private-key "`cat encryption-key.pem`"

  • active_date (Optional[CertDate], default: None ) –

    An optional date that specifies when the certificate becomes active. If you do not specify a value, ActiveDate takes the same value as NotBeforeDate, which is specified by the CA.

  • inactive_date (Optional[CertDate], default: None ) –

    An optional date that specifies when the certificate becomes inactive. If you do not specify a value, InactiveDate takes the same value as NotAfterDate, which is specified by the CA.

  • description (Optional[Description], default: None ) –

    A short description that helps identify the certificate.

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

    Key-value pairs that can be used to group and search for certificates.

Raises:

Source code in docs_src/capo_transfer/_services/async_transfer.py
async def import_certificate(
    self,
    usage: "capo_transfer.types.certificate_usage_type.CertificateUsageType",
    certificate: "capo_transfer.types.certificate_body_type.CertificateBodyType",
    *,
    config_overrides: Optional[AsyncTransferClientConfig] = None,
    certificate_chain: Optional[
        "capo_transfer.types.certificate_chain_type.CertificateChainType"
    ] = None,
    private_key: Optional[
        "capo_transfer.types.private_key_type.PrivateKeyType"
    ] = None,
    active_date: Optional["capo_transfer.types.cert_date.CertDate"] = None,
    inactive_date: Optional["capo_transfer.types.cert_date.CertDate"] = None,
    description: Optional["capo_transfer.types.description.Description"] = None,
    tags: Optional["capo_transfer.types.tags.Tags"] = None,
) -> "capo_transfer.types.import_certificate_response.ImportCertificateResponse":
    """<p>Imports the signing and encryption certificates that you need to create local (AS2) profiles and partner profiles.</p> <p>You can import both the certificate and its chain in the <code>Certificate</code> parameter.</p> <p>After importing a certificate, Transfer Family automatically creates a Amazon CloudWatch metric called <code>DaysUntilExpiry</code> that tracks the number of days until the certificate expires. The metric is based on the <code>InactiveDate</code> parameter and is published daily in the <code>AWS/Transfer</code> namespace.</p> <important> <p>It can take up to a full day after importing a certificate for Transfer Family to emit the <code>DaysUntilExpiry</code> metric to your account.</p> </important> <note> <p>If you use the <code>Certificate</code> parameter to upload both the certificate and its chain, don't use the <code>CertificateChain</code> parameter.</p> </note> <p> <b>CloudWatch monitoring</b> </p> <p>The <code>DaysUntilExpiry</code> metric includes the following specifications:</p> <ul> <li> <p> <b>Units:</b> Count (days)</p> </li> <li> <p> <b>Dimensions:</b> <code>CertificateId</code> (always present), <code>Description</code> (if provided during certificate import)</p> </li> <li> <p> <b>Statistics:</b> Minimum, Maximum, Average</p> </li> <li> <p> <b>Frequency:</b> Published daily</p> </li> </ul>

    Args:
        usage: <p>Specifies how this certificate is used. It can be used in the following ways:</p> <ul> <li> <p> <code>SIGNING</code>: For signing AS2 messages</p> </li> <li> <p> <code>ENCRYPTION</code>: For encrypting AS2 messages</p> </li> <li> <p> <code>TLS</code>: For securing AS2 communications sent over HTTPS</p> </li> </ul>
        certificate: <ul> <li> <p>For the CLI, provide a file path for a certificate in URI format. For example, <code>--certificate file://encryption-cert.pem</code>. Alternatively, you can provide the raw content.</p> </li> <li> <p>For the SDK, specify the raw content of a certificate file. For example, <code>--certificate "`cat encryption-cert.pem`"</code>.</p> </li> </ul> <note> <p>You can provide both the certificate and its chain in this parameter, without needing to use the <code>CertificateChain</code> parameter. If you use this parameter for both the certificate and its chain, do not use the <code>CertificateChain</code> parameter.</p> </note>
        certificate_chain: <p>An optional list of certificates that make up the chain for the certificate that's being imported.</p>
        private_key: <ul> <li> <p>For the CLI, provide a file path for a private key in URI format. For example, <code>--private-key file://encryption-key.pem</code>. Alternatively, you can provide the raw content of the private key file.</p> </li> <li> <p>For the SDK, specify the raw content of a private key file. For example, <code>--private-key "`cat encryption-key.pem`"</code> </p> </li> </ul>
        active_date: <p>An optional date that specifies when the certificate becomes active. If you do not specify a value, <code>ActiveDate</code> takes the same value as <code>NotBeforeDate</code>, which is specified by the CA. </p>
        inactive_date: <p>An optional date that specifies when the certificate becomes inactive. If you do not specify a value, <code>InactiveDate</code> takes the same value as <code>NotAfterDate</code>, which is specified by the CA.</p>
        description: <p>A short description that helps identify the certificate. </p>
        tags: <p>Key-value pairs that can be used to group and search for certificates.</p>

    Raises:
        capo_transfer.errors.internal_service_error.InternalServiceError: <p>This exception is thrown when an error occurs in the Transfer Family service.</p>
        capo_transfer.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_transfer.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource is not found by the Amazon Web ServicesTransfer Family service.</p>
        capo_transfer.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed because the Amazon Web ServicesTransfer Family service is not available.</p>
        capo_transfer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

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

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

        return capo_transfer.types.import_certificate_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ImportCertificate", redact_input=_redact_input),
    )
    input_: capo_transfer.types.import_certificate_request.ImportCertificateRequest = {
        "usage": usage,
        "certificate": certificate,
    }
    if certificate_chain is not None:
        input_["certificate_chain"] = certificate_chain
    if private_key is not None:
        input_["private_key"] = private_key
    if active_date is not None:
        input_["active_date"] = active_date
    if inactive_date is not None:
        input_["inactive_date"] = inactive_date
    if description is not None:
        input_["description"] = description
    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