--- loncom/lonssl.pm 2004/05/26 11:12:58 1.2 +++ loncom/lonssl.pm 2004/05/26 21:45:46 1.3 @@ -1,5 +1,5 @@ # -# $Id: lonssl.pm,v 1.2 2004/05/26 11:12:58 foxr Exp $ +# $Id: lonssl.pm,v 1.3 2004/05/26 21:45:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,24 +55,24 @@ use IO::Socket::SSL; # IO::Socket::SSL sub PromoteClientSocket { - my $PlaintextSocket = shift; - my $CACert = shift; - my $MyCert = shift; - my $KeyFile = shift; - - # To create the ssl socket we need to duplicate the existing - # socket. Otherwise closing the ssl socket will close the plaintext socket - # too: - - open (DUPLICATE, "+>$PlaintextSocket"); - - my $client = IO::Socket::SSL->new_from_fd(fileno(DUPLICATE), - SSL_user_cert => 1, - SSL_key_file => $KeyFile, - SSL_cert_file => $MyCert, - SSL_ca_fie => $$CACert); + my $PlaintextSocket = shift; + my $CACert = shift; + my $MyCert = shift; + my $KeyFile = shift; + + # To create the ssl socket we need to duplicate the existing + # socket. Otherwise closing the ssl socket will close the plaintext socket + # too: + + open (DUPLICATE, "+>$PlaintextSocket"); + + my $client = IO::Socket::SSL->new_from_fd(fileno(DUPLICATE), + SSL_user_cert => 1, + SSL_key_file => $KeyFile, + SSL_cert_file => $MyCert, + SSL_ca_fie => $$CACert); - return $client; # Undef if the client negotiation fails. + return $client; # Undef if the client negotiation fails. } #---------------------------------------------------------------------- @@ -91,27 +91,26 @@ sub PromoteClientSocket { # - Reference to an SSL socket on success # - undef on failure. Reason for failure can be interrogated from # IO::Socket::SSL -sub PromoteServerSocket -{ - my $PlaintextSocket = shift; - my $CACert = shift; - my $MyCert = shift; - my $KeyFile = shift; - - - # To create the ssl socket we need to duplicate the existing - # socket. Otherwise closing the ssl socket will close the plaintext socket - # too: - - open (DUPLICATE, "+>$PlaintextSocket"); - - my $client = IO::Socket::SSL->new_from_fd(fileno(DUPLICATE), - SSL_server => 1, # Server role. - SSL_user_cert => 1, - SSL_key_file => $KeyFile, - SSL_cert_file => $MyCert, - SSL_ca_fie => $$CACert); - return $client; +sub PromoteServerSocket { + my $PlaintextSocket = shift; + my $CACert = shift; + my $MyCert = shift; + my $KeyFile = shift; + + + # To create the ssl socket we need to duplicate the existing + # socket. Otherwise closing the ssl socket will close the plaintext socket + # too: + + open (DUPLICATE, "+>$PlaintextSocket"); + + my $client = IO::Socket::SSL->new_from_fd(fileno(DUPLICATE), + SSL_server => 1, # Server role. + SSL_user_cert => 1, + SSL_key_file => $KeyFile, + SSL_cert_file => $MyCert, + SSL_ca_fie => $$CACert); + return $client; } #------------------------------------------------------------------------- @@ -127,9 +126,9 @@ sub PromoteServerSocket # NONE # sub Close { - my $Socket = shift; + my $Socket = shift; - $Socket->close(SSL_no_shutdown =>1); # Otherwise the parent socket - # gets torn down. + $Socket->close(SSL_no_shutdown =>1); # Otherwise the parent socket + # gets torn down. }