exportCertificate method

Future<ExportCertificateResponse> exportCertificate({
  1. required String certificateArn,
  2. required Uint8List passphrase,
})

Exports a private certificate issued by a private certificate authority (CA) or a public certificate for use anywhere. The exported file contains the certificate, the certificate chain, and the encrypted private key associated with the public key that is embedded in the certificate. For security, you must assign a passphrase for the private key when exporting it.

For information about exporting and formatting a certificate using the ACM console or CLI, see Export a private certificate and Export a public certificate.

May throw InvalidArnException. May throw RequestInProgressException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter certificateArn : An Amazon Resource Name (ARN) of the issued certificate. This must be of the form:

arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012

Parameter passphrase : Passphrase to associate with the encrypted exported private key. If you want to later decrypt the private key, you must have the passphrase. You can use the following OpenSSL command to decrypt a private key. After entering the command, you are prompted for the passphrase.

openssl rsa -in encrypted_key.pem -out decrypted_key.pem

Implementation

Future<ExportCertificateResponse> exportCertificate({
  required String certificateArn,
  required Uint8List passphrase,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CertificateManager.ExportCertificate'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CertificateArn': certificateArn,
      'Passphrase': base64Encode(passphrase),
    },
  );

  return ExportCertificateResponse.fromJson(jsonResponse.body);
}