Created
July 13, 2019 23:03
-
-
Save whelmed/5f8e8f793ed03da268defa4cbc80afd9 to your computer and use it in GitHub Desktop.
Cloud IoT Core Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
REGISTRY_ID=YOUR_ID_HERE | |
REGION=us-YOUR_REGION_HERE | |
PROJECT_ID=YOUR_PROJECT_HERE | |
DEVICE_ID=YOUR_DEVICE_ID_HERE | |
echo "Creating RSA Key for device authentication" | |
openssl genpkey -algorithm RSA -out rsa_private.pem -pkeyopt rsa_keygen_bits:2048 | |
openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem | |
echo "Fetching Google root certificate" | |
wget https://pki.google.com/roots.pem | |
echo "Fetching GCP demo applications from https://github.com/GoogleCloudPlatform/python-docs-samples.git" | |
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git | |
echo "Creating and activating Python 2.7 virtual environment" | |
virtualenv env | |
source env/bin/activate | |
pip install -r python-docs-samples/iot/api-client/mqtt_example/requirements.txt | |
python python-docs-samples/iot/api-client/mqtt_example/cloudiot_mqtt_example.py \ | |
--registry_id=$REGISTRY_ID \ | |
--cloud_region=$REGION \ | |
--project_id=$PROJECT_ID \ | |
--device_id=$DEVICE_ID \ | |
--algorithm=RS256 \ | |
--private_key_file=rsa_private.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment