-
Create a project with the Google Cloud Console, and enable the Cloud IoT Core API.
-
From the Cloud Console, create a service account, download its json credentials file, then set the
GCLOUD_PROJECT
andGOOGLE_APPLICATION_CREDENTIALS
environment variable:export GCLOUD_PROJECT=your-project-id export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
To build and run the sample:
go run manager.go
Before you can connect devices, you will need to generate public / private key credentials to register and connect.
The following commands generate keys suitable for use on a single device.
openssl req -x509 -newkey rsa:2048 -days 3650 -keyout rsa_private.pem -nodes -out \
rsa_cert.pem -subj "/CN=unused"
openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem
openssl ec -in ec_private.pem -pubout -out ec_public.pem