Created
June 22, 2016 14:01
-
-
Save Logioniz/68342fa309cdd44e6dee1d70f7315c40 to your computer and use it in GitHub Desktop.
Mojo client verification and get certificate info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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