Net::S...ARTTLS(3pm)

πŸ“¦
version 0.28 Β· 2 versions
  • 0.28 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.28 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::Server::Mail::ESMTP::STARTTLS πŸ’–

okay bestie, so this is a Perl module from the User Contributed Perl Documentation set, and it's literally the little glow-up your Net::Server::Mail::ESMTP server needs to do TLS. here's the whole vibe ✨


✨ NAME ✨

Net::Server::Mail::ESMTP::STARTTLS β€” a module to support the STARTTLS command in Net::Server::Mail::ESMTP

like. that's it. that's the whole job. and it eats. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole serve, copy-paste ready, no notes:

use strict;
use Net::Server::Mail::ESMTP;

my @local_domains = qw(example.com example.org);
my $server = IO::Socket::INET->new( Listen => 1, LocalPort => 25 );

my $conn;
while($conn = $server->accept)
{
    my $esmtp = Net::Server::Mail::ESMTP->new(
         socket => $conn,
         SSL_config => {
             SSL_cert_file => 'your_cert.pem',
             SSL_key_file => 'your_key.key',
             # Any other options taken by IO::Socket::SSL
         }
    );

    # activate some extensions
    $esmtp->register('Net::Server::Mail::ESMTP::STARTTLS');

    # adding optional STARTTLS handler
    $esmtp->set_callback(STARTTLS => \&tls_started);
    $esmtp->process();
    $conn->close();
}

sub tls_started {
    my ($session) = @_;

    # Now, allow authentication
    $session->register('Net::Server::Mail::ESMTP::AUTH');
}

ok so notice the set_callback(STARTTLS => \&tls_started) bit? that's you getting a lil notification the moment TLS has actually started, and that's when you slide in and register Net::Server::Mail::ESMTP::AUTH. because you are NOT doing auth over plaintext, bestie. not on my watch. 🫢


🌸 DESCRIPTION 🌸

so here's the tea: this module conducts a TLS handshake with the client the second it receives the STARTTLS command. it uses IO::Socket::SSL β€” and it requires 1.831+, no negotiating on that β€” to perform the handshake and secure the traffic. πŸ”₯

there's also one extra option, SSL_config, that gets passed to Net::Server::Mail::ESMTP's constructor. it contains options for IO::Socket::SSL's constructor, so if you wanna know what goes in there, please refer to IO::Socket::SSL's perldoc for details. iykyk πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

please, see Net::Server::Mail. that's the main character this whole module is supporting. 🌈


✨ AUTHOR ✨

this module has been written by Xavier Guimard <x.guimard@free.fr> using libs written by:

  • Mytram <rmytram@gmail.com>
  • Dan Moore "<dan at moore.cx>"

collab of the century tbh πŸŽ€


πŸ’… AVAILABILITY πŸ’…

available on CPAN. yes, THE CPAN.

anonymous Git repository:

git clone git://github.com/rs/net-server-mail.git

Git repository on the web:

<https://github.com/rs/net-server-mail>

go forth and clone, bestie πŸ¦‹


πŸ’€ BUGS πŸ’€

please use the CPAN system to report a bug (http://rt.cpan.org/). don't be shy, don't DM it to me, put it in the system. πŸ™ˆ


Copyright (C) 2009 - Dan Moore <dan at moore.cx>
Copyright (C) 2013 - Mytram <rmytram@gmail.com>
Copyright (C) 2013 - Xavier Guimard <x.guimard@free.fr>

this program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

see http://dev.perl.org/licenses/ for more information.


real talk though β€” this is security code, so like, respect the 1.831+ requirement and actually pass a real cert and key in SSL_config. the vibe is immaculate but the handshake is load-bearing. πŸ’–

okay bye ily, this page was served to you by perl v5.34.0, dated 2022-05-26, straight from the User Contributed Perl Documentation. slay βœ¨πŸ’…πŸ«Ά

πŸ“¦ where this page comes from