I'm trying to register an IoT device with Google Cloud IoT Core, and I'm having issues signing the device public key with a CA certificate installed on Google Cloud (device registry).
Following are Google's requirements:
- CA and device certificates must be X.509v3, encoded in base64, wrapped in -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.
- CA certificates do not need to be self-signed ("root CA"); device certificate must be signed by a specific CA certificate at the registry level.
- Device public keys that are not signed by the registry-level certificates are rejected by Cloud IoT Core.
- CA and device certificates must be in PEM format
After going through previous responses on StackOverflow and elsewhere, this is what I've tried so far (using default config file):
Option 1
- openssl req -x509 -nodes -newkey rsa:2048 -days 365 -keyout ca.key -out ca.crt -subj "/CN=unused"
- openssl req -nodes -newkey rsa:2048 -days 365 -keyout device.key -out device.csr -subj "/CN=unused"
- openssl x509 -req -days 365 -in device.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out device.crt
Option 2
- openssl req -new -x509 -nodes -days 365 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/CN=unused"
- openssl genrsa -out device.key 2048
- openssl req -new -days 365 -key device.key -out device.csr -subj "/CN=unused"
- openssl x509 -req -days 365 -in device.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out device.crt
The certificates get created just fine in both cases, but when I try to register the device with this certificate, I get an error stating that the device certificate could not be verified against the CA certificate.
What am I doing wrong while signing the device certificate? You can ignore Cloud IoT configuration as I've verified it works (without CA certificate).
Many thanks!