certificates
Creates, updates, deletes, gets or lists a certificates resource.
Overview
| Name | certificates |
| Type | Resource |
| Id | aws.iot.certificates |
Fields
The following fields are returned by SELECT queries:
- describe_certificate
- list_certificates
| Name | Datatype | Description |
|---|---|---|
ca_certificate_id | string | The certificate ID of the CA certificate used to sign this certificate. (pattern: <code>(0x)?[a-fA-F0-9]+</code>) |
certificate_arn | string | The ARN of the certificate. |
certificate_id | string | The ID of the certificate. (pattern: <code>(0x)?[a-fA-F0-9]+</code>) |
certificate_mode | string | The mode of the certificate. DEFAULT: A certificate in DEFAULT mode is either generated by Amazon Web Services IoT Core or registered with an issuer certificate authority (CA) in DEFAULT mode. Devices with certificates in DEFAULT mode aren't required to send the Server Name Indication (SNI) extension when connecting to Amazon Web Services IoT Core. However, to use features such as custom domains and VPC endpoints, we recommend that you use the SNI extension when connecting to Amazon Web Services IoT Core. SNI_ONLY: A certificate in SNI_ONLY mode is registered without an issuer CA. Devices with certificates in SNI_ONLY mode must send the SNI extension when connecting to Amazon Web Services IoT Core. For more information about the value for SNI extension, see Transport security in IoT. (DEFAULT, SNI_ONLY) |
certificate_pem | string | The certificate data, in PEM format. (pattern: <code>[\s\S]*</code>) |
creation_date | string (date-time) | The date and time the certificate was created. |
customer_version | integer | The customer version of the certificate. |
generation_id | string | The generation ID of the certificate. |
last_modified_date | string (date-time) | The date and time the certificate was last modified. |
owned_by | string | The ID of the Amazon Web Services account that owns the certificate. (pattern: <code>[0-9]+</code>) |
previous_owned_by | string | The ID of the Amazon Web Services account of the previous owner of the certificate. (pattern: <code>[0-9]+</code>) |
status | string | The status of the certificate. (ACTIVE, INACTIVE, REVOKED, PENDING_TRANSFER, REGISTER_INACTIVE, PENDING_ACTIVATION) |
transfer_data | object | The transfer data. |
validity | object | When the certificate is valid. |
| Name | Datatype | Description |
|---|---|---|
certificate_arn | string | The ARN of the certificate. |
certificate_id | string | The ID of the certificate. (The last part of the certificate ARN contains the certificate ID.) (pattern: <code>(0x)?[a-fA-F0-9]+</code>) |
certificate_mode | string | The mode of the certificate. DEFAULT: A certificate in DEFAULT mode is either generated by Amazon Web Services IoT Core or registered with an issuer certificate authority (CA) in DEFAULT mode. Devices with certificates in DEFAULT mode aren't required to send the Server Name Indication (SNI) extension when connecting to Amazon Web Services IoT Core. However, to use features such as custom domains and VPC endpoints, we recommend that you use the SNI extension when connecting to Amazon Web Services IoT Core. SNI_ONLY: A certificate in SNI_ONLY mode is registered without an issuer CA. Devices with certificates in SNI_ONLY mode must send the SNI extension when connecting to Amazon Web Services IoT Core. (DEFAULT, SNI_ONLY) |
creation_date | string (date-time) | The date and time the certificate was created. |
status | string | The status of the certificate. The status value REGISTER_INACTIVE is deprecated and should not be used. (ACTIVE, INACTIVE, REVOKED, PENDING_TRANSFER, REGISTER_INACTIVE, PENDING_ACTIVATION) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_certificate | select | certificate_id, region | Gets information about the specified certificate. Requires permission to access the DescribeCertificate action. | |
list_certificates | select | region | pageSize, marker, isAscendingOrder | Lists the certificates registered in your Amazon Web Services account. The results are paginated with a default page size of 25. You can use the returned marker to retrieve additional results. Requires permission to access the ListCertificates action. |
create_certificate_from_csr | insert | region, certificateSigningRequest | setAsActive | Creates an X.509 certificate using the specified certificate signing request. Requires permission to access the CreateCertificateFromCsr action. The CSR must include a public key that is either an RSA key with a length of at least 2048 bits or an ECC key from NIST P-256, NIST P-384, or NIST P-521 curves. For supported certificates, consult Certificate signing algorithms supported by IoT. Reusing the same certificate signing request (CSR) results in a distinct certificate. You can create multiple certificates in a batch by creating a directory, copying multiple .csr files into that directory, and then specifying that directory on the command line. The following commands show how to create a batch of certificates given a batch of CSRs. In the following commands, we assume that a set of CSRs are located inside of the directory my-csr-directory: On Linux and OS X, the command is: $ ls my-csr-directory/ | xargs -I {} aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/{} This command lists all of the CSRs in my-csr-directory and pipes each CSR file name to the aws iot create-certificate-from-csr Amazon Web Services CLI command to create a certificate for the corresponding CSR. You can also run the aws iot create-certificate-from-csr part of the command in parallel to speed up the certificate creation process: $ ls my-csr-directory/ | xargs -P 10 -I {} aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/{} On Windows PowerShell, the command to create certificates for all CSRs in my-csr-directory is: > ls -Name my-csr-directory | %{aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/$_} On a Windows command prompt, the command to create certificates for all CSRs in my-csr-directory is: > forfiles /p my-csr-directory /c "cmd /c aws iot create-certificate-from-csr --certificate-signing-request file://@path" |
register_certificate | insert | region, certificatePem | setAsActive | 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. |
create_keys_and_certificate | insert | region | setAsActive | Creates a 2048-bit RSA key pair and issues an X.509 certificate using the issued public key. You can also call CreateKeysAndCertificate over MQTT from a device, for more information, see Provisioning MQTT API. Note This is the only time IoT issues the private key for this certificate, so it is important to keep it in a secure location. Requires permission to access the CreateKeysAndCertificate action. |
update_certificate | update | certificate_id, newStatus, region | Updates the status of the specified certificate. This operation is idempotent. Requires permission to access the UpdateCertificate action. Certificates must be in the ACTIVE state to authenticate devices that use a certificate to connect to IoT. Within a few minutes of updating a certificate from the ACTIVE state to any other state, IoT disconnects all devices that used that certificate to connect. Devices cannot use a certificate that is not in the ACTIVE state to reconnect. | |
delete_certificate | delete | certificate_id, region | forceDelete | Deletes the specified certificate. A certificate cannot be deleted if it has a policy or IoT thing attached to it or if its status is set to ACTIVE. To delete a certificate, first use the DetachPolicy action to detach all policies. Next, use the UpdateCertificate action to set the certificate to the INACTIVE status. Requires permission to access the DeleteCertificate action. |
accept_certificate_transfer | exec | certificate_id, region | setAsActive | Accepts a pending certificate transfer. The default state of the certificate is INACTIVE. To check for pending certificate transfers, call ListCertificates to enumerate your certificates. Requires permission to access the AcceptCertificateTransfer action. |
cancel_certificate_transfer | exec | certificate_id, region | Cancels a pending transfer for the specified certificate. Note Only the transfer source account can use this operation to cancel a transfer. (Transfer destinations can use RejectCertificateTransfer instead.) After transfer, IoT returns the certificate to the source account in the INACTIVE state. After the destination account has accepted the transfer, the transfer cannot be cancelled. After a certificate transfer is cancelled, the status of the certificate changes from PENDING_TRANSFER to INACTIVE. Requires permission to access the CancelCertificateTransfer action. | |
register_certificate_without_ca | exec | region, certificatePem | Register a certificate that does not have a certificate authority (CA). For supported certificates, consult Certificate signing algorithms supported by IoT. | |
reject_certificate_transfer | exec | certificate_id, region | Rejects a pending certificate transfer. After IoT rejects a certificate transfer, the certificate status changes from PENDING_TRANSFER to INACTIVE. To check for pending certificate transfers, call ListCertificates to enumerate your certificates. This operation can only be called by the transfer destination. After it is called, the certificate will be returned to the source's account in the INACTIVE state. Requires permission to access the RejectCertificateTransfer action. | |
transfer_certificate | exec | certificate_id, targetAwsAccount, region | Transfers the specified certificate to the specified Amazon Web Services account. Requires permission to access the TransferCertificate action. You can cancel the transfer until it is accepted by the recipient. No notification is sent to the transfer destination's account. The caller is responsible for notifying the transfer target. The certificate being transferred must not be in the ACTIVE state. You can use the UpdateCertificate action to deactivate it. The certificate must not have any policies attached to it. You can use the DetachPolicy action to detach them. Customer managed key behavior: When you use a customer managed key to encrypt your data and then transfer the certificate to a customer in a different account using the TransferCertificate operation, the certificates will no longer be encrypted by their customer managed key configuration. During the transfer process, certificates are encrypted using Amazon Web Services IoT Core owned keys. While a certificate is in the PENDING_TRANSFER state, it's always protected by Amazon Web Services IoT Core owned keys, regardless of the customer managed key configuration of either the source or destination account. Once the transfer is completed through AcceptCertificateTransfer, RejectCertificateTransfer, or CancelCertificateTransfer, the certificate will be protected by the customer managed key configuration of the account that owns the certificate after the transfer operation: If the transfer is accepted: The certificate is encrypted by the target account's customer managed key configuration. If the transfer is rejected or cancelled: The certificate is protected by the source account's customer managed key configuration. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
certificate_id | string | The ID of the certificate. (The last part of the certificate ARN contains the certificate ID.) |
newStatus | string | The new status. Note: Setting the status to PENDING_TRANSFER or PENDING_ACTIVATION will result in an exception being thrown. PENDING_TRANSFER and PENDING_ACTIVATION are statuses used internally by IoT. They are not intended for developer use. Note: The status value REGISTER_INACTIVE is deprecated and should not be used. |
region | string | AWS region (default: us-east-1) |
targetAwsAccount | string | The Amazon Web Services account. |
forceDelete | boolean | Forces the deletion of a certificate if it is inactive and is not attached to an IoT thing. |
isAscendingOrder | boolean | Specifies the order for results. If True, the results are returned in ascending order, based on the creation date. |
marker | string | The marker for the next set of results. |
pageSize | integer | The result page size. |
setAsActive | boolean | Specifies whether the certificate is active. |
SELECT examples
- describe_certificate
- list_certificates
Gets information about the specified certificate. Requires permission to access the DescribeCertificate action.
SELECT
ca_certificate_id,
certificate_arn,
certificate_id,
certificate_mode,
certificate_pem,
creation_date,
customer_version,
generation_id,
last_modified_date,
owned_by,
previous_owned_by,
status,
transfer_data,
validity
FROM aws.iot.certificates
WHERE certificate_id = '{{ certificate_id }}' -- required
AND region = '{{ region }}' -- required
;
Lists the certificates registered in your Amazon Web Services account. The results are paginated with a default page size of 25. You can use the returned marker to retrieve additional results. Requires permission to access the ListCertificates action.
SELECT
certificate_arn,
certificate_id,
certificate_mode,
creation_date,
status
FROM aws.iot.certificates
WHERE region = '{{ region }}' -- required
AND pageSize = '{{ pageSize }}'
AND marker = '{{ marker }}'
AND isAscendingOrder = '{{ isAscendingOrder }}'
;
INSERT examples
- create_certificate_from_csr
- register_certificate
- create_keys_and_certificate
- Manifest
Creates an X.509 certificate using the specified certificate signing request. Requires permission to access the CreateCertificateFromCsr action. The CSR must include a public key that is either an RSA key with a length of at least 2048 bits or an ECC key from NIST P-256, NIST P-384, or NIST P-521 curves. For supported certificates, consult Certificate signing algorithms supported by IoT. Reusing the same certificate signing request (CSR) results in a distinct certificate. You can create multiple certificates in a batch by creating a directory, copying multiple .csr files into that directory, and then specifying that directory on the command line. The following commands show how to create a batch of certificates given a batch of CSRs. In the following commands, we assume that a set of CSRs are located inside of the directory my-csr-directory: On Linux and OS X, the command is: $ ls my-csr-directory/ | xargs -I {} aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/{} This command lists all of the CSRs in my-csr-directory and pipes each CSR file name to the aws iot create-certificate-from-csr Amazon Web Services CLI command to create a certificate for the corresponding CSR. You can also run the aws iot create-certificate-from-csr part of the command in parallel to speed up the certificate creation process: $ ls my-csr-directory/ | xargs -P 10 -I {} aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/{} On Windows PowerShell, the command to create certificates for all CSRs in my-csr-directory is: > ls -Name my-csr-directory | %{aws iot create-certificate-from-csr --certificate-signing-request file://my-csr-directory/$_} On a Windows command prompt, the command to create certificates for all CSRs in my-csr-directory is: > forfiles /p my-csr-directory /c "cmd /c aws iot create-certificate-from-csr --certificate-signing-request file://@path"
INSERT INTO aws.iot.certificates (
certificateSigningRequest,
region,
setAsActive
)
SELECT
'{{ certificateSigningRequest }}' /* required */,
'{{ region }}',
'{{ setAsActive }}'
RETURNING
certificate_arn,
certificate_id,
certificate_pem
;
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.
INSERT INTO aws.iot.certificates (
certificatePem,
caCertificatePem,
status,
region,
setAsActive
)
SELECT
'{{ certificatePem }}' /* required */,
'{{ caCertificatePem }}',
'{{ status }}',
'{{ region }}',
'{{ setAsActive }}'
RETURNING
certificate_arn,
certificate_id
;
Creates a 2048-bit RSA key pair and issues an X.509 certificate using the issued public key. You can also call CreateKeysAndCertificate over MQTT from a device, for more information, see Provisioning MQTT API. Note This is the only time IoT issues the private key for this certificate, so it is important to keep it in a secure location. Requires permission to access the CreateKeysAndCertificate action.
INSERT INTO aws.iot.certificates (
region,
setAsActive
)
SELECT
'{{ region }}',
'{{ setAsActive }}'
RETURNING
certificate_arn,
certificate_id,
certificate_pem,
key_pair
;
# Description fields are for documentation purposes
- name: certificates
props:
- name: region
value: "{{ region }}"
description: Required parameter for the certificates resource.
- name: certificateSigningRequest
value: "{{ certificateSigningRequest }}"
- name: certificatePem
value: "{{ certificatePem }}"
description: |
The PEM of a certificate.
- name: caCertificatePem
value: "{{ caCertificatePem }}"
description: |
The PEM of a certificate.
- name: status
value: "{{ status }}"
valid_values: ['ACTIVE', 'INACTIVE', 'REVOKED', 'PENDING_TRANSFER', 'REGISTER_INACTIVE', 'PENDING_ACTIVATION']
- name: setAsActive
value: {{ setAsActive }}
description: Specifies whether the certificate is active.
description: Specifies whether the certificate is active.
UPDATE examples
- update_certificate
Updates the status of the specified certificate. This operation is idempotent. Requires permission to access the UpdateCertificate action. Certificates must be in the ACTIVE state to authenticate devices that use a certificate to connect to IoT. Within a few minutes of updating a certificate from the ACTIVE state to any other state, IoT disconnects all devices that used that certificate to connect. Devices cannot use a certificate that is not in the ACTIVE state to reconnect.
UPDATE aws.iot.certificates
SET
-- No updatable properties
WHERE
certificate_id = '{{ certificate_id }}' --required
AND newStatus = '{{ newStatus }}' --required
AND region = '{{ region }}' --required;
DELETE examples
- delete_certificate
Deletes the specified certificate. A certificate cannot be deleted if it has a policy or IoT thing attached to it or if its status is set to ACTIVE. To delete a certificate, first use the DetachPolicy action to detach all policies. Next, use the UpdateCertificate action to set the certificate to the INACTIVE status. Requires permission to access the DeleteCertificate action.
DELETE FROM aws.iot.certificates
WHERE certificate_id = '{{ certificate_id }}' --required
AND region = '{{ region }}' --required
AND forceDelete = '{{ forceDelete }}'
;
Lifecycle Methods
- accept_certificate_transfer
- cancel_certificate_transfer
- register_certificate_without_ca
- reject_certificate_transfer
- transfer_certificate
Accepts a pending certificate transfer. The default state of the certificate is INACTIVE. To check for pending certificate transfers, call ListCertificates to enumerate your certificates. Requires permission to access the AcceptCertificateTransfer action.
EXEC aws.iot.certificates.accept_certificate_transfer
@certificate_id='{{ certificate_id }}' --required,
@region='{{ region }}' --required,
@setAsActive={{ setAsActive }}
;
Cancels a pending transfer for the specified certificate. Note Only the transfer source account can use this operation to cancel a transfer. (Transfer destinations can use RejectCertificateTransfer instead.) After transfer, IoT returns the certificate to the source account in the INACTIVE state. After the destination account has accepted the transfer, the transfer cannot be cancelled. After a certificate transfer is cancelled, the status of the certificate changes from PENDING_TRANSFER to INACTIVE. Requires permission to access the CancelCertificateTransfer action.
EXEC aws.iot.certificates.cancel_certificate_transfer
@certificate_id='{{ certificate_id }}' --required,
@region='{{ region }}' --required
;
Register a certificate that does not have a certificate authority (CA). For supported certificates, consult Certificate signing algorithms supported by IoT.
EXEC aws.iot.certificates.register_certificate_without_ca
@region='{{ region }}' --required
@@json=
'{
"certificatePem": "{{ certificatePem }}",
"status": "{{ status }}"
}'
;
Rejects a pending certificate transfer. After IoT rejects a certificate transfer, the certificate status changes from PENDING_TRANSFER to INACTIVE. To check for pending certificate transfers, call ListCertificates to enumerate your certificates. This operation can only be called by the transfer destination. After it is called, the certificate will be returned to the source's account in the INACTIVE state. Requires permission to access the RejectCertificateTransfer action.
EXEC aws.iot.certificates.reject_certificate_transfer
@certificate_id='{{ certificate_id }}' --required,
@region='{{ region }}' --required
@@json=
'{
"rejectReason": "{{ rejectReason }}"
}'
;
Transfers the specified certificate to the specified Amazon Web Services account. Requires permission to access the TransferCertificate action. You can cancel the transfer until it is accepted by the recipient. No notification is sent to the transfer destination's account. The caller is responsible for notifying the transfer target. The certificate being transferred must not be in the ACTIVE state. You can use the UpdateCertificate action to deactivate it. The certificate must not have any policies attached to it. You can use the DetachPolicy action to detach them. Customer managed key behavior: When you use a customer managed key to encrypt your data and then transfer the certificate to a customer in a different account using the TransferCertificate operation, the certificates will no longer be encrypted by their customer managed key configuration. During the transfer process, certificates are encrypted using Amazon Web Services IoT Core owned keys. While a certificate is in the PENDING_TRANSFER state, it's always protected by Amazon Web Services IoT Core owned keys, regardless of the customer managed key configuration of either the source or destination account. Once the transfer is completed through AcceptCertificateTransfer, RejectCertificateTransfer, or CancelCertificateTransfer, the certificate will be protected by the customer managed key configuration of the account that owns the certificate after the transfer operation: If the transfer is accepted: The certificate is encrypted by the target account's customer managed key configuration. If the transfer is rejected or cancelled: The certificate is protected by the source account's customer managed key configuration.
EXEC aws.iot.certificates.transfer_certificate
@certificate_id='{{ certificate_id }}' --required,
@targetAwsAccount='{{ targetAwsAccount }}' --required,
@region='{{ region }}' --required
@@json=
'{
"transferMessage": "{{ transferMessage }}"
}'
;