mldvx4 has asked for the wisdom of the Perl Monks concerning the following question:
Greetings. With the code down below I get the this error:
connect: SSL connect attempt failed error:0A000086:SSL routines::certificate verify failedWhat is the right way to allow Net::MQTT::Simple::SSL to manage self-signed certificates?
#!/usr/bin/perl use Config::Tiny; use Net::MQTT::Simple::SSL; use strict; use warnings; my $config = $0; $config =~ s/\.pl$/.config/; my $configuration = Config::Tiny->read($config) or die("Could not read configuration file '$config': $!\n"); my $cpath = '/home/me/Certs'; my $mqtt = Net::MQTT::Simple::SSL->new("203.0.113.46:8883", { SSL_ca_file => "$cpath/certificate-authority.crt", SSL_cert_file => "$cpath/notifications-client.crt", SSL_key_file => "$cpath/notifications-client.key", # SSL_verify_mode => 0, }); $mqtt->login($configuration->{mqtt}->{account}, $configuration->{mqtt}->{password} ); $mqtt->subscribe('notifications', \&received); $mqtt->run(); $mqtt->disconnect(); exit(0); sub received { my ($topic, $message) = (@_); if ( $message =~ m/\x3b/ || $message =~ m/[\x00-\x08\x0a-\x1f]/ ) { warn "notify\tMalformed message\n"; } elsif ( $topic =~ m/\x3b/ || $topic =~ m/[\x00-\x08\x0a-\x1f]/ ) { warn "notify\tMalformed message\n"; } else { my ($title, $message) = ( $message =~ m/^([^\x09]+)\t(.*)$/ ); system("notify-send", "--icon=info", $title, $message); } }
If I uncomment SSL_verify_mode then it connects, but that seems rather unsafe and may partially defeat the encryption I would guess. I would like to find a way to verify the self-signed certificates here.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Self-signed certificates and Net::MQTT::Simple::SSL
by choroba (Cardinal) on Aug 20, 2024 at 16:11 UTC | |
by mldvx4 (Friar) on Aug 20, 2024 at 16:51 UTC |