Client certificate requirements
- The client certificate must be signed by the CA designated by
listeners.[MQTTS listener].tls.caCertificateFilename in services.json. - The Common Name (CN) attribute of the client certificate must be set to a valid username in the FairCom broker.
FairCom broker requirements
- A CA certificate must be designated for the
listeners.[MQTTS listener].tls.caCertificateFilenameblock ofservices.json. - The
services.jsonmqtt.authenticationMethodsarray must contain"clientCertificate".
If this array contains other authentication methods, clients can also authenticate using those methods.
We recommend removing the "none" option when using client certificates.
Steps
-
Create a client certificate with a CN that matches an existing username and is signed by the CA we designate in
services.json. - In
services.json, configure the MQTTS listenercaCertificateFilenameproperty to the CA that signed the client certificates. - In
services.json, configure the MQTTS listenerserverCertificateFilenameproperty to a server certificate signed by the same CA. - In
services.json, set the"requireClientCertificate"property to"true"for the MQTTS listener. - In
services.json, remove the"none"option from themqtt.authenticationMethodssection. - In
ctsrvr.cfgadd a semicolon to theCOMM_PROTOCOL FSHAREMMline to comment it out. It should look like this:;COMM_PROTOCOL FSHAREMM - In
ctsrvr.cfgadd (or modify) the following lines:;Here is where you can activate (un-comment) SSL SUBSYSTEM COMM_PROTOCOL SSL { ;This is the file name in your server's directory. SERVER_CERTIFICATE_FILE ./web/fccert.pem ;For SSL you can specify (un-comment) a debug log file name. DEBUG_LOG ssl.log ;Here you can restrict access to SSL ONLY. SSL_CONNECTIONS_ONLY YES ;Require clients to provide a x509 certificate. VERIFY_CLIENT_CERTIFICATE YES ;Use x509 client certificate for database authentication. x509_AUTHENTICATION YES ;Use the SUBJECT:CN from the client's certificate as their user name. x509_PATH CN ;Set the ciphers that will be allowed. SSL_CIPHERS AES256-SHA256:AES256-GCM-SHA38:DHE-RSA-AES256-SHA256:AES256-GCM-SHA384 }
Note that the file specified bySERVER_CERTIFICATE_FILEis the same file specified in step 3 above. This file is typically kept in the<FairCom installation>/server/web/directory. Once those changes have been made, you should start or restart the server. - Confirm certificates are working using the client of your choice, or by running the following Python script:
import time import paho.mqtt.client as mqtt mqtts_client = mqtt.Client( client_id = "MQTTS client certs" ) mqtts_client.tls_set( ca_certs = "/FairCom/ca.crt", certfile = "/FairCom/ClientAdmin.crt", keyfile = "/FairCom/ClientAdmin.key" ) mqtts_client.loop_start() mqtts_client.connect( "127.0.0.1", port = 8883 ) time.sleep( 2 ) mqtts_client.publish( "test/SimpleMqttsClientCert", "Simple test message" ) mqtts_client.disconnect() mqtts_client.loop_stop()
Note that the value in thetime.sleep( 2 )line may need to be adjusted for your environment.