| 1 | package DJabberd::Connection::OldSSLClientIn; | ||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 20 | ▶ | use base 'DJabberd::Connection::ClientIn'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 20 | ▶ | use DJabberd::Stanza::StartTLS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 20 | ▶ | use Net::SSLeay; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 20 | ▶ | use constant SSL_MODE_ENABLE_PARTIAL_WRITE => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 20 | ▶ | use constant SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER => 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 20 | ▶ | use constant SSL_MODE_AUTO_RETRY => 4; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 13 | 0 | my ($class, $sock, $server) = @_; | |||||||||
| 14 | 0 | my $self = $class->SUPER::new($sock, $server); | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | my $ctx = Net::SSLeay::CTX_new() | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | or die("Failed to create SSL_CTX $!"); | ||||||||||
| 18 | |||||||||||
| 19 | # compared to the StartTLS, we specifically do not insist on TLS here. | ||||||||||
| 20 | # let client do SSL 2/3/whatever. TODO: perhaps force SSL v3? | ||||||||||
| 21 | # $Net::SSLeay::ssl_version = 10; # Insist on TLSv1 | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | and Net::SSLeay::die_if_ssl_error("ssl ctx set options"); | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | Net::SSLeay::CTX_set_mode($ctx, SSL_MODE_ENABLE_PARTIAL_WRITE) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | and Net::SSLeay::die_if_ssl_error("ssl ctx set options"); | ||||||||||
| 28 | |||||||||||
| 29 | # Following will ask password unless private key is not encrypted | ||||||||||
| 30 | 0 | Net::SSLeay::CTX_use_RSAPrivateKey_file ($ctx, $server->ssl_private_key_file, # server-key.pem', | |||||||||
| 31 | &Net::SSLeay::FILETYPE_PEM); | ||||||||||
| 32 | 0 | Net::SSLeay::die_if_ssl_error("private key"); | |||||||||
| 33 | |||||||||||
| 34 | 0 | Net::SSLeay::CTX_use_certificate_file ($ctx, $server->ssl_cert_file, # 'server-cert.pem', | |||||||||
| 35 | &Net::SSLeay::FILETYPE_PEM); | ||||||||||
| 36 | 0 | Net::SSLeay::die_if_ssl_error("certificate"); | |||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | if ($server->ssl_cert_chain_file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | Net::SSLeay::CTX_use_certificate_chain_file ($ctx, $server->ssl_cert_chain_file); # 'server-cert-chain.pem', | |||||||||
| 40 | 0 | Net::SSLeay::die_if_ssl_error("certificate chain file"); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | my $ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | $self->{ssl} = $ssl; | |||||||||
| 46 | |||||||||||
| 47 | 0 | DJabberd::Stanza::StartTLS->finalize_ssl_negotiation($self, $ssl, $ctx); | |||||||||
| 48 | |||||||||||
| 49 | 0 | return $self; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 20 | 1; | |||||||||