I think that there is a way to optimize this. I used Net::SSLeay::OO. I managed to get a server together and a client, but the client needs some more work. The server seems ok.
#!/usr/bin/perl #server.pl use strict; use warnings; use Net::SSLeay::OO::SSL; use Net::SSLeay::OO::Context; use Net::SSLeay::OO::X509; use Net::SSLeay::OO::Constants qw(VERIFY_PEER); use Socket qw(:DEFAULT :crlf); print "This is Net::SSLeay $Net::SSLeay::VERSION\n"; $Net::SSLeay::trace = 3; my $port = shift || 8080; my $proto = getprotobyname 'tcp'; socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!"; setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!"; my $paddr = sockaddr_in($port, INADDR_ANY); bind(SERVER, $paddr) or die "bind: $!"; listen(SERVER, SOMAXCONN) or die "listen: $!"; print "Server started on port $port", "\n"; my $client_addr; my $client_ip = 'localhost'; while ($client_addr = accept(CLIENT, SERVER)) { my ($client_port, $client_ip) = sockaddr_in($client_addr); my $client_ipnum = inet_ntoa($client_ip); my $client_host = gethostbyname($client_ip); print "Hello, CLIENT"; close CLIENT; } my $ctx = Net::SSLeay::OO::Context->new; $ctx->set_cipher_list('ALL'), $ctx->set_verify(1); my $ssl = Net::SSLeay::OO::SSL->new( ctx => $ctx ); my $cert = $ssl->get_peer_certificate; verify($ssl); sub verify { use Net::SSLeay::OO::X509::Name; my ( $ok, $x509_cert ) = @_; my $name = $x509_cert->get_subject_name; print "$$: **** Verify called ($ok)\n"; if ($x509_cert) { print "$$: Certificate:\n"; print " Common name is: " . $name->cn . "\n"; print " Subject Name: " . $x509_cert->get_subject_name->onelin +e . "\n"; print " Issuer Name: " . $x509_cert->get_issuer_name->oneline +. "\n"; print " AltNames: " . $x509_cert->get_subjectAltNames->oneline + . "\n"; print " notBefore: " . $x509_cert->get_notBefore($x509_cert)-> +oneline . "\n"; print " notAfter: " . $x509_cert->get_notAfter($x509_cert)->on +eline . "\n"; } return 1; }
And here's the client:
#!/usr/bin/perl #client.pl use strict; use warnings; use Socket qw(:DEFAULT :crlf); my $host = shift || 'localhost'; my $port = shift || 8080; my $proto = getprotobyname('tcp'); my $iaddr = inet_aton($host); my $paddr = sockaddr_in($port, $iaddr); socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "socket: $!"; connect(SOCKET, $paddr) or die "connect: $!"; my $line; if ($line) { print $line; } close SOCKET or die "close: $!";

In reply to Re: Which module for SSL certificate access? by Khen1950fx
in thread Which module for SSL certificate access? by WoodyWeaver

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.