createCertificateAuthority method

Future<CreateCertificateAuthorityResponse> createCertificateAuthority({
  1. required CertificateAuthorityConfiguration certificateAuthorityConfiguration,
  2. required CertificateAuthorityType certificateAuthorityType,
  3. String? idempotencyToken,
  4. RevocationConfiguration? revocationConfiguration,
  5. List<Tag>? tags,
})

Creates a root or subordinate private certificate authority (CA). You must specify the CA configuration, the certificate revocation list (CRL) configuration, the CA type, and an optional idempotency token to avoid accidental creation of multiple CAs. The CA configuration specifies the name of the algorithm and key size to be used to create the CA private key, the type of signing algorithm that the CA uses, and X.500 subject information. The CRL configuration specifies the CRL expiration period in days (the validity period of the CRL), the Amazon S3 bucket that will contain the CRL, and a CNAME alias for the S3 bucket that is included in certificates issued by the CA. If successful, this action returns the Amazon Resource Name (ARN) of the CA.

ACM Private CAA assets that are stored in Amazon S3 can be protected with encryption. For more information, see Encrypting Your CRLs.

May throw InvalidArgsException. May throw InvalidPolicyException. May throw InvalidTagException. May throw LimitExceededException.

Parameter certificateAuthorityConfiguration : Name and bit size of the private key algorithm, the name of the signing algorithm, and X.500 certificate subject information.

Parameter certificateAuthorityType : The type of the certificate authority.

Parameter idempotencyToken : Alphanumeric string that can be used to distinguish between calls to CreateCertificateAuthority. For a given token, ACM Private CA creates exactly one CA. If you issue a subsequent call using the same token, ACM Private CA returns the ARN of the existing CA and takes no further action. If you change the idempotency token across multiple calls, ACM Private CA creates a unique CA for each unique token.

Parameter revocationConfiguration : Contains a Boolean value that you can use to enable a certification revocation list (CRL) for the CA, the name of the S3 bucket to which ACM Private CA will write the CRL, and an optional CNAME alias that you can use to hide the name of your bucket in the CRL Distribution Points extension of your CA certificate. For more information, see the CrlConfiguration structure.

Parameter tags : Key-value pairs that will be attached to the new private CA. You can associate up to 50 tags with a private CA. For information using tags with IAM to manage permissions, see Controlling Access Using IAM Tags.

Implementation

Future<CreateCertificateAuthorityResponse> createCertificateAuthority({
  required CertificateAuthorityConfiguration
      certificateAuthorityConfiguration,
  required CertificateAuthorityType certificateAuthorityType,
  String? idempotencyToken,
  RevocationConfiguration? revocationConfiguration,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(
      certificateAuthorityConfiguration, 'certificateAuthorityConfiguration');
  ArgumentError.checkNotNull(
      certificateAuthorityType, 'certificateAuthorityType');
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    1,
    36,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'ACMPrivateCA.CreateCertificateAuthority'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CertificateAuthorityConfiguration': certificateAuthorityConfiguration,
      'CertificateAuthorityType': certificateAuthorityType.toValue(),
      if (idempotencyToken != null) 'IdempotencyToken': idempotencyToken,
      if (revocationConfiguration != null)
        'RevocationConfiguration': revocationConfiguration,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateCertificateAuthorityResponse.fromJson(jsonResponse.body);
}