Last active
September 10, 2021 11:40
-
-
Save vedangj044/831ecdec5197b6b76a095bca6c11eb5a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Assuming you already have `drg login ..` | |
rm z* | |
openssl req -x509 -nodes -newkey rsa:4096 -keyout zapp-key.pem -out zapp-cert.pem -days 365 -subj "/O=Drogue IoT/OU=Cloud/CN=app1" | |
openssl req -nodes -newkey rsa:4096 -keyout zdevice-private.pem -days 365 -subj "/O=Drogue IoT/OU=app1/CN=d7" > zdevice-cert.req | |
cat zdevice-cert.req | openssl x509 -req -extfile ca.cnf -extensions "san_ext" -out zdevice.crt -days 3650 -CA zapp-cert.pem -CAkey zapp-key.pem -set_serial 2 | |
CERT=$(base64 -w0 < "zapp-cert.pem") | |
APP=cert1 | |
DEVICE="O=Drogue IoT, OU=app1, CN=d7" | |
drg delete app $APP || true | |
drg create app $APP --spec "{\"trustAnchors\": {\"anchors\": [ {\"certificate\": \"$CERT\"} ]}}" | |
drg create device --app $APP "$DEVICE" --spec '{"credentials": {}}' | |
mqtt pub -v -h mqtt.sandbox.drogue.cloud -p 443 --cert zdevice.crt --key zdevice-private.pem -s -t temp -m '{\"temp\":42}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ca.cnf