Greetings. With the code down below I get the this error:

connect: SSL connect attempt failed error:0A000086:SSL routines::certificate verify failed

What 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.


In reply to Self-signed certificates and Net::MQTT::Simple::SSL by mldvx4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.