--- loncom/lonssl.pm 2004/05/27 10:26:19 1.5 +++ loncom/lonssl.pm 2004/05/28 09:37:03 1.6 @@ -1,5 +1,5 @@ # -# $Id: lonssl.pm,v 1.5 2004/05/27 10:26:19 foxr Exp $ +# $Id: lonssl.pm,v 1.6 2004/05/28 09:37:03 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -23,7 +23,7 @@ # # http://www.lon-capa.org/ # - +package lonssl; # lonssl.pm # This file contains common functions used by lond and lonc when # negotiating the exchange of the session encryption key via an @@ -33,8 +33,9 @@ use strict; -# CPAN modules: +# CPAN/Standard modules: +use English; use IO::Socket::INET; use IO::Socket::SSL; @@ -75,23 +76,24 @@ $perlvar = LONCAPA::Configuration::read_ # IO::Socket::SSL sub PromoteClientSocket { - my $PlaintextSocket = shift; - my $CACert = shift; - my $MyCert = shift; - my $KeyFile = shift; - + my ($PlaintextSocket, + $CACert, + $MyCert, + $KeyFile) = @ARG; + + # 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. } @@ -112,10 +114,11 @@ sub PromoteClientSocket { # - 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; + my ($PlaintextSocket, + $CACert, + $MyCert, + $KeyFile) = @ARG; + # To create the ssl socket we need to duplicate the existing @@ -163,12 +166,12 @@ sub Close { # the certificate authority. The second element of the list is the name # of the owner of the certificate. sub GetPeerCertificate { - my $SSLSocket = shift; - - my $CertOwner = $SSLSocket->peer_certificate("owner"); - my $CertCA = $SSLSocket->peer_certificate("authority"); - - return \($CertCA, $CertOwner); + my $SSLSocket = shift; + + my $CertOwner = $SSLSocket->peer_certificate("owner"); + my $CertCA = $SSLSocket->peer_certificate("authority"); + + return \($CertCA, $CertOwner); } #---------------------------------------------------------------------------- # @@ -182,31 +185,31 @@ sub GetPeerCertificate { # sub CertificateFile { - # I need some perl variables from the configuration file for this: - - my $CertificateDir = $perlvar->{lonCertificateDirectory}; - my $CaFilename = $perlvar->{lonnetCertificateAuthority}; - my $CertFilename = $perlvar->{lonnetCertificate}; - - # Ensure the existence of these variables: - - if((!$CertificateDir) || (!$CaFilename) || (!$CertFilename)) { - return undef; - } - - # Build the actual filenames and check for their existence and - # readability. - - my $CaFilename = $CertificateDir.$pathsep.$CaFilename; - my $CertFilename = $CertificateDir.$pathsep.$CertFilename; - - if((! -r $CaFilename) || (! -r $CertFilename)) { - return undef; - } - - # Everything works fine!! - - return \($CaFilename, $CertFilename); + # I need some perl variables from the configuration file for this: + + my $CertificateDir = $perlvar->{lonCertificateDirectory}; + my $CaFilename = $perlvar->{lonnetCertificateAuthority}; + my $CertFilename = $perlvar->{lonnetCertificate}; + + # Ensure the existence of these variables: + + if((!$CertificateDir) || (!$CaFilename) || (!$CertFilename)) { + return undef; + } + + # Build the actual filenames and check for their existence and + # readability. + + my $CaFilename = $CertificateDir.$pathsep.$CaFilename; + my $CertFilename = $CertificateDir.$pathsep.$CertFilename; + + if((! -r $CaFilename) || (! -r $CertFilename)) { + return undef; + } + + # Everything works fine!! + + return \($CaFilename, $CertFilename); } #------------------------------------------------------------------------ @@ -220,26 +223,26 @@ sub CertificateFile { # sub KeyFile { - # I need some perl variables from the configuration file for this: - - my $CertificateDir = $perlvar->{lonCertificateDirectory}; - my $KeyFilename = $perlvar->{lonnetPrivateKey}; - - # Ensure the variables exist: - - if((!$CertificateDir) || (!$KeyFilename)) { - return undef; - } - - # Build the actual filename and ensure that it not only exists but - # is also readable: - - my $KeyFilename = $CertificateDir.$pathsep.$KeyFilename; - if(! (-r $KeyFilename)) { - return undef; - } - - return $KeyFilename; + # I need some perl variables from the configuration file for this: + + my $CertificateDir = $perlvar->{lonCertificateDirectory}; + my $KeyFilename = $perlvar->{lonnetPrivateKey}; + + # Ensure the variables exist: + + if((!$CertificateDir) || (!$KeyFilename)) { + return undef; + } + + # Build the actual filename and ensure that it not only exists but + # is also readable: + + my $KeyFilename = $CertificateDir.$pathsep.$KeyFilename; + if(! (-r $KeyFilename)) { + return undef; + } + + return $KeyFilename; } 1; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.