importCertificate method
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.
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
May throw InternalServiceError.
May throw InvalidRequestException.
May throw ResourceNotFoundException.
May throw ServiceUnavailableException.
Parameter certificate :
-
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`".
Parameter usage :
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
Parameter activeDate :
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.
Parameter certificateChain :
An optional list of certificates that make up the chain for the
certificate that's being imported.
Parameter description :
A short description that helps identify the certificate.
Parameter inactiveDate :
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.
Parameter privateKey :
-
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`"
Parameter tags :
Key-value pairs that can be used to group and search for certificates.
Implementation
Future<ImportCertificateResponse> importCertificate({
required String certificate,
required CertificateUsageType usage,
DateTime? activeDate,
String? certificateChain,
String? description,
DateTime? inactiveDate,
String? privateKey,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'TransferService.ImportCertificate'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Certificate': certificate,
'Usage': usage.value,
if (activeDate != null) 'ActiveDate': unixTimestampToJson(activeDate),
if (certificateChain != null) 'CertificateChain': certificateChain,
if (description != null) 'Description': description,
if (inactiveDate != null)
'InactiveDate': unixTimestampToJson(inactiveDate),
if (privateKey != null) 'PrivateKey': privateKey,
if (tags != null) 'Tags': tags,
},
);
return ImportCertificateResponse.fromJson(jsonResponse.body);
}