The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Parse::SNI - parse Server Name Indication from TLS handshake

SYNOPSIS

    use Parse::SNI;
    use IO::Socket;

    my $srv = IO::Socket::INET->new( LocalAddr => 'localhost', LocalPort => 443, Listen => 1 ) or die $@;

    while ( my $cli = $srv->accept() ) {
        $cli->sysread( my $buf, 4096 ) or next;
        my $sni = parse_sni($buf);
    }

FUNCTIONS

parse_sni($data)

Tries to parse SNI from the passed data string, which should contain complete initial TLS handshake record from the client. On success returns SNI string in scalar context and (SNI string, start position of SNI in $data) in list context. On error dies with human readable message. One of the usefull error message to parse is /Incomplete TLS record: expected \d+ bytes, got \d+/. This may occure when u didn't read all of initial handshake from the client. You should catch it, read remaining message from the client and try again.

This function exported by default.

SEE ALSO

sniproxy

COPYRIGHT

Copyright Oleg G <oleg@cpan.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.