INSTAR MQTTv5 with Python - Client Connection

Adding a Personal TLS Certificate
Generating a Private Certificate Authority
INSTAR Cameras already have a valid CA certificate installed that we can use when we access the MQTT service via the camera's DDNS address (e.g. ab1234.ddns3-instar.de). Alternatively, we can upload our own self-signed certificate.
To do this we will use OpenSSL to generate an X.509 digital certificate that uses the X.509 PKI (short for public key infrastructure) standard. This digital certificate allows us to confirm that a specific public key belongs to the subject included within the certificate. There is an identity that issues the certificate and its details are also included in the certificate.
Create a new directory named mosquitto_certificates enter the folder and run the following OpenSSL commands:
openssl genrsa -out ca.key 2048
openssl req -x509 -new -nodes -key ca.key -sha512 -days 3650 -out ca.crt
Since we will not be verifying the certificate, it does not really matter what you fill out here:
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:INSTAR MQTTv5
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:INSTAR MQTTv5
Email Address []:
After running the previous commands, we will have the following two files in the mqtt_certificates directory:
ca.key: Certificate authority keyca.crt: Certificate authority certificate file
Creating a Certificate for the Mosquitto Server
We need generate a new private key and use the key to and generates the server certificate: file
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr
It does not really matter what you fill out here. Except - you have to set the FQDN to an address/url through which you will be contacting the MQTT service:
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:INSTAR MQTTv5
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.118
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
The command generates a server.crt file with the signed X.509 digital certificate for the Mosquitto server:
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -sha512
Signature ok
subject=C = AU, ST = Some-State, O = INSTAR MQTTv5, CN = 192.168.2.118
Getting CA Private Key
After running the previous commands, we will have the following 3 new files in the mqtt_certificates directory:
server.key: Server keyserver.csr: Server certificate signing requestserver.crt: Server certificate file
Upload to your INSTAR Camera
Your INSTAR camera has two expectations that we need to full fill before uploading our certificates:
- Combine the
server.keyandserver.crtin a single fileserver.pem:
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAy/8kPEhDg9rJ3Rb60Vax7pgtUTKLQ0hi1BZl3OBH/JuKmvVO
...
jLeAC8HlqWJMNlm8DWSIGWZSBmgS11Dakw8gGxNJ4UThUwnx2XrnLA==
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIDKzCCAhMCFArfrELy23ar8AW8OKk5WXn7TLa/MA0GCSqGSIb3DQEBDQUAMFIx
...
PlC3SfWTSo3XJlPjU2xRToRG4rO7oyxN/0X7dGQLCrSJjSJoC3Jeky91EpIouwU=
-----END CERTIFICATE-----
- Open the
ca.crtand re-save it asca.pem.
CA Store
Now take the ca.pem and upload it to the INSTAR CA Store:

Server Certificate
Next, upload the server.pem file as our camera's TLS certificate:

Don't forget to toggle it on before leaving this menu.