user91579631 user91579631 - 1 month ago 29
Node.js Question

Security key and cert for mosca MQTT broker

I am trying to set up Mosca MQTT broker which is based on node.js

From the documentation below,
https://github.com/mcollina/mosca/wiki/TLS-SSL-Configuration

var mosca = require('mosca')

var SECURE_KEY = __dirname + '/../../test/secure/tls-key.pem';
var SECURE_CERT = __dirname + '/../../test/secure/tls-cert.pem';


Where do I get
tls-key.pem
and
tls-cert.pem
?

Answer

From the link https://github.com/mcollina/mosca/wiki/TLS-SSL-Configuration in your question, you are directed to another link https://nodejs.org/api/tls.html#tls_tls_ssl

Now, follow the instructions in this link.

$ openssl genrsa -out tls-key.pem 2048
$ openssl req -new -sha256 -key tls-key.pem -out ryans-csr.pem
$ openssl x509 -req -in ryans-csr.pem -signkey tls-key.pem -out tls-cert.pem

There you go. You should have your pem files.