Certificates

Usage

from mbed_cloud import CertificatesAPI
from mbed_cloud.certificates import CertificateType

certificatesApi = CertificatesAPI()
# Create a new developer certificate
print("Creating new developer certificate...")
certificate = {
  "name": "my_dev_certificate",
  "type": CertificateType.developer
}
new_certificate = certificatesApi.add_developer_certificate(**certificate)
print("Successfully created developer certificate with id: %r" % new_certificate.id)

# Update certificate
updated_certificate = certificatesApi.update_certificate(new_certificate.id,
                                           description="my updated certificate")
# Delete the certificate
print("Attempting to delete certificate...")
certificatesApi.delete_certificate(updated_certificate.id)
print("Successfully deleted certificate (ID: %r)" % updated_certificate.id)

More examples

See full listing of examples in the examples directory.

Reference

class mbed_cloud.certificates.CertificatesAPI(params=None)

Certificates API reference.

add_certificate(name, type, certificate_data, signature=None, **kwargs)

Add a new BYOC certificate.

Parameters:
  • name (str) – name of the certificate (Required)
  • type (str) – type of the certificate. Values: lwm2m or bootstrap (Required)
  • certificate_data (str) – X509.v3 trusted certificate in PEM format. (Required)
  • signature (str) – This parameter has been DEPRECATED in the API and does not need to be provided.
  • status (str) – Status of the certificate. Allowed values: “ACTIVE” | “INACTIVE”.
  • description (str) – Human readable description of this certificate, not longer than 500 characters.
Returns:

Certificate object

Return type:

Certificate

add_developer_certificate(name, **kwargs)

Add a new developer certificate.

Parameters:
  • name (str) – name of the certificate (Required)
  • description (str) – Human readable description of this certificate, not longer than 500 characters.
Returns:

Certificate object

Return type:

Certificate

delete_certificate(certificate_id)

Delete a certificate.

Parameters:certificate_id (str) – The certificate id (Required)
Returns:void
get_certificate(certificate_id)

Get certificate by id.

Parameters:certificate_id (str) – The certificate id (Required)
Returns:Certificate object
Return type:Certificate
list_certificates(**kwargs)

List certificates registered to organisation.

Currently returns partially populated certificates. To obtain the full certificate object: [get_certificate(certificate_id=cert[‘id’]) for cert in list_certificates]

Parameters:
  • limit (int) – The number of certificates to retrieve.
  • order (str) – The ordering direction, ascending (asc) or descending (desc).
  • after (str) – Get certificates after/starting at given certificate_id.
  • filters (dict) – Dictionary of filters to apply: type (eq), expire (eq), owner (eq)
Returns:

list of Certificate objects

Return type:

Certificate

update_certificate(certificate_id, **kwargs)

Update a certificate.

Parameters:
  • certificate_id (str) – The certificate id (Required)
  • certificate_data (str) – X509.v3 trusted certificate in PEM format.
  • signature (str) – This parameter has been DEPRECATED in the API and does not need to be provided.
  • type (str) – type of the certificate. Values: lwm2m or bootstrap.
  • status (str) – Status of the certificate. Allowed values: “ACTIVE” | “INACTIVE”.
  • description (str) – Human readable description of this certificate, not longer than 500 characters.
Returns:

Certificate object

Return type:

Certificate

class mbed_cloud.certificates.Certificate(dictionary)

Describes device certificate object.

account_id

The UUID of the account.

Return type:str
certificate_data

X509.v3 trusted certificate data in PEM format.

Returns:The certificate data.
Return type:str
created_at

Creation UTC time RFC3339.

Return type:datetime
description

Human readable description of this certificate.

Returns:The description of this certificate.
Return type:str
developer_certificate

The PEM format X.509 developer certificate.

Set only for developer certificate. :rtype: str

developer_private_key

The PEM format developer private key associated with the certificate.

Set only for developer certificate. :rtype: str

device_mode

The device mode

Return type:str
enrollment_mode

The enrollment_mode of the certificate.

Returns:The enrollment_mode of this certificate.
Return type:str
header_file

The content of the security.c file that is flashed into the device

to provide the security credentials. Set only for developer certificate. :rtype: str

id

ID of this certificate.

Returns:The id of this certificate.
Return type:str
issuer

Issuer of the certificate.

Returns:The issuer of this certificate.
Return type:str
name

Certificate name.

Returns:The name of this certificate.
Return type:str
owner_id

The UUID of the owner.

Return type:str
server_certificate

The PEM format X.509 server certificate that is used to validate

the server certificate that is received during the TLS/DTLS handshake.

Return type:str
server_uri

The URI to which the client needs to connect to.

Return type:str
signature

The signature of the certificate.

This parameter has been DEPRECATED in the API and is no longer used.

Returns:The signature of this certificate.
Return type:str
status

The status of the certificate.

Returns:The status of this certificate.
Return type:str
subject

Subject of the certificate.

Returns:The subject of this certificate.
Return type:str
type

Certificate type.

Returns:The type of the certificate.
Return type:CertificateType
update_attributes(updates)

Update attributes.

updated_at

Update UTC time RFC3339.

Return type:datetime
validity

Expiration time in UTC formatted as RFC3339.

Returns:The validity of this certificate.
Return type:datetime