--- loncom/configuration/SSL.pm 2017/05/26 03:43:43 1.6 +++ loncom/configuration/SSL.pm 2018/08/18 22:07:53 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Checksum installed LON-CAPA modules and some configuration files # -# $Id: SSL.pm,v 1.6 2017/05/26 03:43:43 raeburn Exp $ +# $Id: SSL.pm,v 1.7 2018/08/18 22:07:53 raeburn Exp $ # # The LearningOnline Network with CAPA # @@ -31,7 +31,7 @@ package LONCAPA::SSL; use strict; use lib '/home/httpd/lib/perl/'; -use Apache::lonlocal(); +use Apache::lonlocal; use Apache::lonnet(); use Apache::loncommon(); use Apache::lonhtmlcommon(); @@ -48,7 +48,7 @@ sub print_certstatus { 'avai' => 'Available', 'yes' => 'Yes', 'no' => 'No', - 'cn' => 'Common Name', + 'cn' => 'Common Name (CN)', 'start' => 'Valid From', 'end' => 'Valid To', 'alg' => 'Signature Algorithm', @@ -62,15 +62,19 @@ sub print_certstatus { 'expired' => 'Expired', 'future' => 'Future validity', 'nokey' => 'No key', - 'otherkey' => 'No matching key', + 'otherkey' => 'No matching key', + 'revoked' => 'Revoked by CA', + 'wrongcn' => 'Incorrect CN', ); my @files = qw(key host hostname ca); my @fields = qw(status cn start end alg size email); foreach my $server (sort(keys(%{$servers}))) { - my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server,$context); + my $hostname = $servers->{$server}; + my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server, + $hostname, + $context); if ($result eq 'ok' && ref($hashref) eq 'HASH') { if ($target eq 'web') { - my $hostname = &Apache::lonnet::hostname($server); $message .= "
$hostname ($server)". &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row()."\n"; @@ -81,6 +85,7 @@ sub print_certstatus { } else { $message .= $server.':'; } + my %csr; foreach my $file (@files) { if ($target eq 'web') { $message .= &Apache::loncommon::start_data_table_row()."\n". @@ -146,9 +151,19 @@ sub print_certstatus { } elsif ($target eq 'web') { $display = &Apache::lonhtmlcommon::confirm_success($display); } - } elsif (($display eq 'nokey') || ($display eq 'otherkey')) { + } elsif (($display eq 'nokey') || ($display eq 'otherkey') || + ($display eq 'revoked') || ($display eq 'expired') || + ($display eq 'wrongcn')) { if ($target eq 'web') { - $display = $lt{$display}; + $display = $lt{$display}; + } + if (ref($hashref->{$file.'-csr'}) eq 'HASH') { + if ($hashref->{$file.'-csr'}->{$item} eq 'ok') { + if ($target eq 'web') { + $display .= '
'.&mt('(New request awaiting signature)'); + } + $csr{$file} = 1; + } } } } elsif ($item eq 'start') { @@ -180,9 +195,23 @@ sub print_certstatus { } else { $message .= 'no,'; } + if ((($file eq 'host') || ($file eq 'hostname')) && + (ref($hashref->{$file.'-csr'}) eq 'HASH')) { + if ($hashref->{$file.'-csr'}->{'status'} eq 'ok') { + if ($target eq 'web') { + my $colspan = scalar(@fields); + $message .= ''. + &mt('Request for [_1] awaiting signature', + $lt{$file}).''; + } + $csr{$file} = 1; + } + } foreach my $item (@fields) { if ($target eq 'web') { - $message .= ' '; + unless ($csr{$file}) { + $message .= ' '; + } } else { $message .= ','; } @@ -198,6 +227,18 @@ sub print_certstatus { if ($target eq 'web') { $message .= &Apache::loncommon::end_data_table().'
'; } else { + if (keys(%csr)) { + foreach my $file (keys(%csr)) { + if (ref($hashref->{$file.'-csr'}) eq 'HASH') { + $message .= $file.'-csr=yes,'; + foreach my $item (@fields) { + $message .= $hashref->{$file.'-csr'}->{$item}.','; + } + $message =~ s/,$//; + $message .= '&'; + } + } + } $message =~ s/\&$//; } $message .= "\n";