Skip to content

Instantly share code, notes, and snippets.

@Logioniz
Created June 22, 2016 14:01
Show Gist options
  • Save Logioniz/68342fa309cdd44e6dee1d70f7315c40 to your computer and use it in GitHub Desktop.
Save Logioniz/68342fa309cdd44e6dee1d70f7315c40 to your computer and use it in GitHub Desktop.
Mojo client verification and get certificate info
Generate 2 certficate:
openssl req -nodes -new -x509 -keyout client.key -out client.cert
openssl req -nodes -new -x509 -keyout server.key -out server.cert
run server:
morbo server.pl -l 'https://*:3000?cert=./server.cert&key=./server.key&ca=client.cert'
run client:
openssl s_client -connect 127.0.0.1:3000 -cert client.cert -key client.key
GET / HTTP/1.0
#!/usr/bin/perl
use Mojo::IOLoop;
use Mojolicious::Lite;
use IO::Socket::SSL;
get '/' => sub {
my $c = shift;
warn ref Mojo::IOLoop->stream($c->tx->connection)->handle;
warn Mojo::IOLoop->stream($c->tx->connection)->handle->peer_certificate('cn');
$c->render(text => 'qwe');
};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment