registerCertificate method

Future<RegisterCertificateResponse> registerCertificate({
  1. required String certificatePem,
  2. String? caCertificatePem,
  3. bool? setAsActive,
  4. CertificateStatus? status,
})

Registers a device certificate with IoT in the same certificate mode as the signing CA. If you have more than one CA certificate that has the same subject field, you must specify the CA certificate that was used to sign the device certificate being registered.

Requires permission to access the RegisterCertificate action.

May throw CertificateConflictException. May throw CertificateStateException. May throw CertificateValidationException. May throw InternalFailureException. May throw InvalidRequestException. May throw ResourceAlreadyExistsException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException.

Parameter certificatePem : The certificate data, in PEM format.

Parameter caCertificatePem : The CA certificate used to sign the device certificate being registered.

Parameter setAsActive : A boolean value that specifies if the certificate is set to active.

Valid values: ACTIVE | INACTIVE

Parameter status : The status of the register certificate request. Valid values that you can use include ACTIVE, INACTIVE, and REVOKED.

Implementation

Future<RegisterCertificateResponse> registerCertificate({
  required String certificatePem,
  String? caCertificatePem,
  bool? setAsActive,
  CertificateStatus? status,
}) async {
  final $query = <String, List<String>>{
    if (setAsActive != null) 'setAsActive': [setAsActive.toString()],
  };
  final $payload = <String, dynamic>{
    'certificatePem': certificatePem,
    if (caCertificatePem != null) 'caCertificatePem': caCertificatePem,
    if (status != null) 'status': status.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/certificate/register',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return RegisterCertificateResponse.fromJson(response);
}