go-aws-iot-utils

module
v0.0.0-...-0660bb8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2016 License: MIT

README

go-aws-iot-utils

mqttclient

mqttclient helps to construct an aws iot mqtt client.

Example usage:

import "github.com/wattx/go-aws-iot-utils/mqttclient"

clientConfig := mqttclient.ClientConfig{
		ClientID:    "client-id",
		Endpoint:    "aws-mqtt-endpoint",
		CertsFolder: "./certs",
}


mqttc, onConnect, err := mqttclient.NewClient(clientConfig)
if err != nil {
    log.Fatal(err)
}

Endpoint usually has a format of tls://FOOBAR.iot.eu-west-1.amazonaws.com:8883

onConnect is used to notify when reconnect to the mqtt broker is happening. Since aws iot doesn't support persistent sessions you can use as a work around for refreshing your subscriptions.

CertsFolder should contain:

  • certificate.pem.crt
  • private.pem.key
  • root-CA.crt
How to get iot certificates
  1. Log to: https://.signin.aws.amazon.com/console
  2. AWS-iot -> Create-a-resource -> certificate
  3. Download the private key and certificate files to your machine (you don't need the private key file).
  4. Get the last certificate from:
wget https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem
  1. Rename the certificates:
mv VeriSign-Class\ 3-Public-Primary-Certification-Authority-G5.pem root-CA.crt
mv <your-num>-certificate.pem.crt certificate.pem.crt
mv <your-num>-private.pem.key private.pem.key
  1. Move the renamed certificates to CertsFolder (for example ./certs)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL