Net::MQTT::Simple::SSL - Minimal MQTT version 3 interface with SSL support
Contents
Description
A subclass of Net::MQTT::Simple that adds SSL/TLS.
Like its base class, a server can be given on the "use" line, in which case "publish" and "retain" are
exported so that they can be used as simple functions. This interface supports configuration via
environment variables, but not via explicit options in code.
The object oriented interface does support explicit SSL configuration. See IO::Socket::SSL for a
comprehensive overview of all the options that can be supplied to the constructor, "new".
Environmentvariables
Instead of explicitly specifying the SSL options in the constructor, they can be set with environment
variables. These are overridden by options given to "new".
MQTT_SIMPLE_SSL_INSECURE Set to something other than 0 to disable SSL validation.
MQTT_SIMPLE_SSL_CA Path to the CA certificate or a directory of certificates. IO::Socket::SSL can
find the CA path automatically on some systems.
MQTT_SIMPLE_SSL_CERT
MQTT_SIMPLE_SSL_KEY Path to the client certificate file and its key file.
License
Pick your favourite OSI approved license :)
http://www.opensource.org/licenses/alphabeticalName
Net::MQTT::Simple::SSL - Minimal MQTT version 3 interface with SSL support
See Also
Net::MQTT::Simple
perl v5.36.0 2023-10-30 Net::MQTT::Simple::SSL(3pm)
Synopsis
# Specifying SSL parameters in environment variables
export MQTT_SIMPLE_SSL_CA=/etc/ssl/ca.crt
export MQTT_SIMPLE_SSL_CERT=/etc/ssl/mqtt.crt
export MQTT_SIMPLE_SSL_KEY=/etc/ssl/mqtt.key
perl -MNet::MQTT::Simple::SSL=mosquitto.example.org \
-nle'retain "topic/here" => $_'
# Specifying explicit SSL parameters
use Net::MQTT::Simple::SSL;
my $mqtt = Net::MQTT::Simple::SSL->new("mosquitto.example.org", {
SSL_ca_file => '/etc/ssl/ca.crt',
SSL_cert_file => '/etc/ssl/mqtt.crt',
SSL_key_file => '/etc/ssl/mqtt.key',
});
$mqtt->publish("topic/here" => "Message here");
$mqtt->retain( "topic/here" => "Message here");
