Blog | G5 Cyber Security

Embedded System Security: Certificates

TL;DR

This guide explains how to use authentication certificates in an embedded system (microcontroller) to secure communication and device identity. We’ll cover generating a certificate, storing it securely on the microcontroller, and using it for verification.

1. Understanding Certificates & Why Use Them?

Certificates are digital documents that prove the identity of your embedded system or another communicating party. They’re essential for:

Certificates rely on a Certificate Authority (CA), which issues the certificates after verifying identity.

2. Generating Your Certificate

You’ll need to create a certificate for your device. This can be done using tools like OpenSSL or cloud-based services.

Example using OpenSSL:

openssl req -x509 -newkey rsa:2048 -keyout device.key -out device.crt -days 365

This creates a private key (device.key) and a self-signed certificate (device.crt) valid for 365 days.

3. Securely Storing the Certificate on the Microcontroller

Storing the certificate securely is crucial. Here are some options:

Important Considerations:

4. Implementing Certificate Verification

Your microcontroller code needs to verify certificates received from other devices (or use its own certificate for authentication).

Example (simplified) using a hypothetical library:

bool verify_certificate(const char *received_cert, const char *trusted_ca_list) {
  if (check_chain_of_trust(received_cert, trusted_ca_list)) {
    if (is_expired(received_cert)) {
      return false;
    }
    if (validate_hostname(received_cert, expected_hostname)) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}

5. Using the Certificate for Communication

Once verified, use the certificate to establish a secure connection (e.g., TLS/SSL).

Most embedded systems use a TLS/SSL library (e.g., wolfSSL, mbedTLS) which provides functions for managing certificates and establishing secure connections.

6. Regular Updates

Certificates expire! Implement a mechanism to update the certificate on your device periodically:

Exit mobile version