Skip to content

Instantly share code, notes, and snippets.

@hortoncd
Created June 22, 2020 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hortoncd/210bb0146182582a0ab7a6f1b973a952 to your computer and use it in GitHub Desktop.
Save hortoncd/210bb0146182582a0ab7a6f1b973a952 to your computer and use it in GitHub Desktop.

mqtt tooling

mqttfx (graphical pub/sub client for testing)

  • install
brew cask install mqttfx

mosquitto - mqtt server / broker

  • install
brew install mosquitto
  • configure
vi /usr/local/opt/mosquitto/etc/mosquitto/mosquitto.conf
  • homebrew service
less /usr/local/Cellar/mosquitto/1.6.10/homebrew.mxcl.mosquitto.plist
  • manual startup
/usr/local/opt/mosquitto/sbin/mosquitto -c /usr/local/opt/mosquitto/etc/mosquitto/mosquitto.conf
  • command line publisher publish client
/usr/local/opt/mosquitto/bin/mosquitto_pub 
/usr/local/opt/mosquitto/bin/mosquitto_pub -h localhost -p 1833 -t test/topic -m "this is a test"

easy-rsa

  • setup CA
mkdir infra-ca
cd infra-ca/
./easyrsa init-pki
./easyrsa build-ca
vi vars
openssl x509 -noout -text /Users/hortoncd/git/home/easy-rsa/easyrsa3/pki/ca.crt
cat /Users/hortoncd/git/home/easy-rsa/easyrsa3/pki/ca.crt | openssl x509 -noout -text  | less
  • generate and sign a server cert
./easyrsa gen-req mqtt.internal.opencod.in
./easyrsa sign-req server mqtt.internal.opencod.in
openssl rsa -in easyrsa3/pki/private/mqtt.internal.opencod.in.key -out easyrsa3/pki/private/mqtt.internal.opencod.in.ckey 
cat easyrsa3/pki/private/mqtt.internal.opencod.in.ckey | openssl rsa -text -noout | less
  • generate and sign a client cert
./easyrsa gen-req chrome.internal.opencod.in
./easyrsa sign-req client chrome.internal.opencod.in
cat easyrsa3/pki/issued/chrome.internal.opencod.in.crt | openssl x509 -noout -text  | less
openssl rsa -in easyrsa3/pki/private/chrome.internal.opencod.in.key -out easyrsa3/pki/private/chrome.internal.opencod.in.ckey 

test script for publishing

bash ./pub-test test/topic specific test from command line

ruby script for testing (initially only subscribing)

mkdir lita-mqtt
cd lita-mqtt
vi Gemfile
bundle install --path ./vendor
vi test.rb
bundle exec ./test.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment