Skip to content

Instantly share code, notes, and snippets.

Created April 16, 2012 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2400559 to your computer and use it in GitHub Desktop.
Save anonymous/2400559 to your computer and use it in GitHub Desktop.
IO::Socket::SSL & NPN
##### SSL client example #####
use IO::Socket::SSL;
my $client = IO::Socket::SSL->new(
PeerAddr=>"encrypted.google.com:https",
SSL_npn_protocols=>['spdy/2','http/1.1'],
) or die;
warn "Negotiated:", $client->next_proto_negotiated(), "\n";
##### SSL server example #####
# try connect via: openssl s_client -connect localhost:5443 -nextprotoneg proto1,protoB,protoA,proto2
use IO::Socket::SSL;
my $server = IO::Socket::SSL->new(
LocalAddr=>'127.0.0.1',
LocalPort=>5443,
Proto=>'tcp',
Listen => 5,
SSL_npn_protocols=>['protoX','protoA','protoB'],
) or die;
my $s = $server->accept();
warn "Negotiated:", $s->next_proto_negotiated(), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment