--- loncom/LondConnection.pm 2018/08/07 17:12:09 1.57 +++ loncom/LondConnection.pm 2018/12/14 02:05:38 1.62 @@ -1,7 +1,7 @@ # This module defines and implements a class that represents # a connection to a lond daemon. # -# $Id: LondConnection.pm,v 1.57 2018/08/07 17:12:09 raeburn Exp $ +# $Id: LondConnection.pm,v 1.62 2018/12/14 02:05:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -165,16 +165,24 @@ host the remote lond is on. This host is port number the remote lond is listening on. +=item lonid + + lonid of the remote lond is listening on. + +=item deflonid + + default lonhostID of the remote lond is listening on. + =cut sub new { - my ($class, $DnsName, $Port, $lonid) = @_; + my ($class, $DnsName, $Port, $lonid, $deflonid, $loncaparev) = @_; if (!$ConfigRead) { ReadConfig(); $ConfigRead = 1; } - &Debug(4,$class."::new( ".$DnsName.",".$Port.",".$lonid.")\n"); + &Debug(4,$class."::new( ".$DnsName.",".$Port.",".$lonid.",".$deflonid.",".$loncaparev.")\n"); my ($conntype,$gotconninfo,$allowinsecure); if ((ref($secureconf{'connto'}) eq 'HASH') && @@ -203,6 +211,8 @@ sub new { # Now create the object... my $self = { Host => $DnsName, LoncapaHim => $lonid, + LoncapaDefid => $deflonid, + LoncapaRev => $loncaparev, Port => $Port, State => "Initialized", AuthenticationMode => "", @@ -279,15 +289,16 @@ sub new { my ($ca, $cert) = lonssl::CertificateFile; my $sslkeyfile = lonssl::KeyFile; my $badcertfile = lonssl::has_badcert_file($self->{LoncapaHim}); + my ($loncaparev) = ($perlvar{'lonVersion'} =~ /^[\'\"]?([\w.\-]+)[\'\"]?$/); if (($conntype ne 'no') && (defined($ca)) && (defined($cert)) && (defined($sslkeyfile)) && (!exists($badcerts{$self->{LoncapaHim}})) && !$badcertfile) { $self->{AuthenticationMode} = "ssl"; - $self->{TransactionRequest} = "init:ssl:$perlvar{'lonVersion'}\n"; + $self->{TransactionRequest} = "init:ssl:$loncaparev\n"; } elsif ($self->{InsecureOK}) { # Allowed to do insecure: $self->{AuthenticationMode} = "insecure"; - $self->{TransactionRequest} = "init::$perlvar{'lonVersion'}\n"; + $self->{TransactionRequest} = "init::$loncaparev\n"; } else { # Not allowed to do insecure... $socket->close; @@ -530,6 +541,7 @@ sub Readable { } } elsif ($self->{State} eq "ReceivingKey") { my $buildkey = $self->{TransactionReply}; + chomp($buildkey); my $key = $self->{LoncapaHim}.$perlvar{'lonHostID'}; $key=~tr/a-z/A-Z/; $key=~tr/G-P/0-9/; @@ -1056,6 +1068,8 @@ sub ExchangeKeysViaSSL { my $self = shift; my $socket = $self->{Socket}; my $peer = $self->{LoncapaHim}; + my $peerdef = $self->{LoncapaDefid}; + my $loncaparev = $self->{LoncapaRev}; # Get our signed certificate, the certificate authority's # certificate and our private key file. All of these @@ -1065,9 +1079,9 @@ sub ExchangeKeysViaSSL { $SSLCertificate) = lonssl::CertificateFile(); my $SSLKey = lonssl::KeyFile(); my $CRLFile; - unless ($crlchecked{$peer}) { + unless ($crlchecked{$peerdef}) { $CRLFile = lonssl::CRLFile(); - $crlchecked{$peer} = 1; + $crlchecked{$peerdef} = 1; } # Promote our connection to ssl and read the key from lond. @@ -1076,7 +1090,9 @@ sub ExchangeKeysViaSSL { $SSLCertificate, $SSLKey, $peer, - $CRLFile); + $peerdef, + $CRLFile, + $loncaparev); if(defined $SSLSocket) { my $key = <$SSLSocket>; lonssl::Close($SSLSocket);