Documentation

Mistake on this page? Email us

Certificates API

The API can be initalized with a .env file in the working directory with the following values

MBED_CLOUD_SDK_API_KEY=

and optionally

MBED_CLOUD_SDK_HOST= (defaults to https://api.us-east-1.mbedcloud.com)

OR

This API is initialized with ConnectionOptions.

To create an instance of this API in Node.js:

var PelionDMSDK = require("mbed-cloud-sdk");

var certificates = new PelionDMSDK.CertificatesApi({
    apiKey: "<Pelion DM API Key>"
});

To create an instance of this API in the browser:

<script src="<pelion-dm-sdk>/bundles/certificates.min.js"></script>

<script>
    var certificates = new MbedCloudSDK.CertificatesApi({
        apiKey: "<Pelion DM API Key>"
    });
</script>

Hierarchy

  • CertificatesApi

Index

Constructors

constructor

Methods

addCertificate

  • Adds a certificate

    Example:

    // Signature is a Base64 encoded signature of the account ID hashed with SHA256
    certificates.addCertificate({
        name: 'CertName',
        description: 'SDK generated cert',
        type: 'bootstrap',
        signature: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        certificateData: '-----BEGIN CERTIFICATE-----\nMIICFzCCAbygAwIBAgIQX ... EPSDKEF\n-----END CERTIFICATE-----'
    })
    .then(certificate => {
        // Utilize certificate here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Certificate>

    Promise containing certificate

  • Adds a certificate

    Example:

    // Signature is a Base64 encoded signature of the account ID hashed with SHA256
    certificates.addCertificate({
        name: 'CertName',
        description: 'SDK generated cert',
        type: 'bootstrap',
        signature: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        certificateData: '-----BEGIN CERTIFICATE-----\nMIICFzCCAbygAwIBAgIQX ... EPSDKEF\n-----END CERTIFICATE-----'
    }, function(error, certificate) {
        if (error) throw error;
        // Utilize certificate here
    });

    Parameters

    Returns void

addDeveloperCertificate

  • Adds a generated developer certificate

    Example:

    certificates.addDeveloperCertificate({
        name: 'CertName',
        description: 'SDK generated cert'
    })
    .then(certificate => {
        // Utilize certificate here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Certificate>

    Promise containing certificate

  • Adds a generated developer certificate

    Example:

    certificates.addDeveloperCertificate({
        name: 'CertName',
        description: 'SDK generated cert'
    }, function(error, certificate) {
        if (error) throw error;
        // Utilize certificate here
    });

    Parameters

    Returns void

deleteCertificate

  • deleteCertificate(certificateId: string): Promise<void>
  • Deletes a certificate

    Example:

    certificates.deleteCertificate('015c64f76a7b02420a01230a00000000')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • certificateId: string

      The certificate ID

    Returns Promise<void>

    Promise containing any error

  • deleteCertificate(certificateId: string, callback: CallbackFn<void>): void
  • Deletes a certificate

    Example:

    certificates.deleteCertificate('015c64f76a7b02420a01230a00000000', function(error) {
        if (error) throw error;
    });

    Parameters

    • certificateId: string

      The certificate ID

    • callback: CallbackFn<void>

      A function that is passed the return arguments (error, void)

    Returns void

getCertificate

  • getCertificate(certificateId: string): Promise<Certificate>
  • Get details of a certificate

    Example:

    certificates.getCertificate('015c64f76a7b02420a01230a00000000')
    .then(certificate => {
        // Utilize certificate here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • certificateId: string

      The certificate ID

    Returns Promise<Certificate>

    Promise containing the certificate

  • Get details of a certificate

    Example:

    certificates.getCertificate('015c64f76a7b02420a01230a00000000', function(error, certificate) {
        if (error) throw error;
        // Utilize certificate here
    });

    Parameters

    • certificateId: string

      The certificate ID

    • callback: CallbackFn<Certificate>

      A function that is passed the return arguments (error, certificate)

    Returns void

getLastApiMetadata

  • getLastApiMetadata(): Promise<ApiMetadata>
  • Get meta data for the last Pelion Device Management API call

    Returns Promise<ApiMetadata>

    Promise of meta data

  • getLastApiMetadata(callback: CallbackFn<ApiMetadata>): void
  • Get meta data for the last Pelion Device Management API call

    Parameters

    • callback: CallbackFn<ApiMetadata>

      A function that is passed the arguments (error, meta data)

    Returns void

listCertificates

  • List certificates

    Currently returns partially populated certificates. To obtain the full certificate object use getCertificate.

    Example:

    certificates.listCertificates({
        limit: 5,
        order: 'ASC',
        filter: {
            type: { $eq: 'bootstrap' }
        }
    })
    .then(certificates => {
        // Utilize certificates here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<Certificate>>

    Promise of listResponse

  • List certificates

    Currently returns partially populated certificates. To obtain the full certificate object use getCertificate.

    Example:

    certificates.listCertificates({
        limit: 5,
        order: 'ASC',
        filter: {
            type: { $eq: 'bootstrap' }
        }
    }, function(error, certificates) {
        if (error) throw error;
        // Utilize certificates here
    });

    Parameters

    Returns void

updateCertificate

  • Updates a certificate

    Example:

    // Signature is a Base64 encoded signature of the account ID hashed with SHA256
    certificates.updateCertificate({
        name: 'CertName',
        description: 'SDK generated cert',
        type: 'bootstrap',
        signature: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        certificateData: '-----BEGIN CERTIFICATE-----\nMIICFzCCAbygAwIBAgIQX ... EPSDKEF\n-----END CERTIFICATE-----'
    })
    .then(certificate => {
        // Utilize certificate here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Certificate>

    Promise containing certificate

  • Updates a certificate

    Example:

    // Signature is a Base64 encoded signature of the account ID hashed with SHA256
    certificates.updateCertificate({
        name: 'CertName',
        description: 'SDK generated cert',
        type: 'bootstrap',
        signature: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        certificateData: '-----BEGIN CERTIFICATE-----\nMIICFzCCAbygAwIBAgIQX ... EPSDKEF\n-----END CERTIFICATE-----'
    }, function(error, certificate) {
        if (error) throw error;
        // Utilize certificate here
    });

    Parameters

    Returns void