Annotation of loncom/configuration/SSL.pm, revision 1.4
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Checksum installed LON-CAPA modules and some configuration files
3: #
1.4 ! raeburn 4: # $Id: SSL.pm,v 1.3 2016/08/01 18:03:53 raeburn Exp $
1.1 raeburn 5: #
6: # The LearningOnline Network with CAPA
7: #
8: # Copyright Michigan State University Board of Trustees
9: #
10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11: #
12: # LON-CAPA is free software; you can redistribute it and/or modify
13: # it under the terms of the GNU General Public License as published by
14: # the Free Software Foundation; either version 2 of the License, or
15: # (at your option) any later version.
16: #
17: # LON-CAPA is distributed in the hope that it will be useful,
18: # but WITHOUT ANY WARRANTY; without even the implied warranty of
19: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: # GNU General Public License for more details.
21: #
22: # You should have received a copy of the GNU General Public License
23: # along with LON-CAPA; if not, write to the Free Software
24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25: #
26: # /home/httpd/html/adm/gpl.txt
27: #
28: # http://www.lon-capa.org/
29: #
30:
31: package LONCAPA::SSL;
32: use strict;
33: use lib '/home/httpd/lib/perl/';
34: use Apache::lonlocal();
35: use Apache::lonnet();
36: use Apache::loncommon();
37: use Apache::lonhtmlcommon();
1.4 ! raeburn 38: use DateTime;
! 39: use DateTime::Format::x509;
1.1 raeburn 40: use LONCAPA;
41:
42: sub print_certstatus {
43: my ($servers,$target,$context) = @_;
44: return unless (ref($servers) eq 'HASH');
45: my $message;
46: my %lt = &Apache::lonlocal::texthash (
47: 'file' => 'File',
48: 'avai' => 'Available',
49: 'yes' => 'Yes',
50: 'no' => 'No',
51: 'cn' => 'Common Name',
52: 'start' => 'Valid From',
53: 'end' => 'Valid To',
54: 'alg' => 'Signature Algorithm',
55: 'size' => 'Public Key Size',
56: 'status' => 'Status',
57: 'email' => 'E-mail',
58: 'key' => 'Private Key',
59: 'host' => 'Connections Certificate',
60: 'hostname' => 'Replication Certificate',
61: 'ca' => 'LON-CAPA CA Certificate',
1.4 ! raeburn 62: 'expired' => 'Expired',
! 63: 'future' => 'Future validity',
1.1 raeburn 64: );
65: my @files = qw(key host hostname ca);
66: my @fields = qw(status cn start end alg size email);
67: foreach my $server (sort(keys(%{$servers}))) {
68: my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server,$context);
69: if ($result eq 'ok' && ref($hashref) eq 'HASH') {
70: if ($target eq 'web') {
1.2 raeburn 71: my $hostname = &Apache::lonnet::hostname($server);
1.1 raeburn 72: $message .= "<fieldset><legend>$hostname ($server)</legend>".
73: &Apache::loncommon::start_data_table().
74: &Apache::loncommon::start_data_table_header_row()."\n";
75: foreach my $item ('file','avai',@fields) {
76: $message .= '<th>'.$lt{$item}.'</th>';
77: }
78: $message .= &Apache::loncommon::end_data_table_header_row()."\n";
79: } else {
80: $message .= $server.':';
81: }
82: foreach my $file (@files) {
83: if ($target eq 'web') {
84: $message .= &Apache::loncommon::start_data_table_row()."\n".
85: '<td>'.$lt{$file}.'</td>';
86: } else {
87: $message .= $file.'=';
88: }
89: if (ref($hashref->{$file}) eq 'HASH') {
1.4 ! raeburn 90: my ($starttime,$endtime,$dateinvalid);
1.1 raeburn 91: if ($target eq 'web') {
92: $message .= '<td>'.$lt{'yes'}.'</td>';
93: } else {
94: $message .= $lt{'yes'}.',';
95: }
1.4 ! raeburn 96: unless ($file eq 'key') {
! 97: if ($hashref->{$file}->{'end'} ne '') {
! 98: my $dt = DateTime::Format::x509->parse_datetime($hashref->{$file}->{'end'});
! 99: if (ref($dt)) {
! 100: $endtime = $dt->epoch;
! 101: if ($endtime < time) {
! 102: $dateinvalid = $lt{'expired'};
! 103: }
! 104: }
! 105: }
! 106: if ($hashref->{$file}->{'start'} ne '') {
! 107: my $dt = DateTime::Format::x509->parse_datetime($hashref->{$file}->{'start'});
! 108: if (ref($dt)) {
! 109: $starttime = $dt->epoch;
! 110: if ($starttime > time) {
! 111: unless ($dateinvalid) {
! 112: $dateinvalid = $lt{'future'};
! 113: }
! 114: }
! 115: }
! 116: }
! 117: }
1.1 raeburn 118: foreach my $item (@fields) {
119: my $display = $hashref->{$file}->{$item};
1.4 ! raeburn 120: if ($item eq 'status') {
! 121: if ($file eq 'key') {
! 122: if ($display =~ /ok$/) {
! 123: if ($target eq 'web') {
! 124: $display = &Apache::lonhtmlcommon::confirm_success($display);
! 125: }
! 126: }
! 127: } elsif ($file eq 'ca') {
! 128: if ($dateinvalid) {
! 129: $display = $dateinvalid;
! 130: } elsif ($target eq 'web') {
! 131: $display = &Apache::lonhtmlcommon::confirm_success($display);
! 132: }
! 133: } elsif ($display =~ /^ok/) {
! 134: if ($dateinvalid) {
! 135: $display = $dateinvalid;
! 136: } elsif ($target eq 'web') {
! 137: $display = &Apache::lonhtmlcommon::confirm_success($display);
! 138: }
! 139: }
! 140: } elsif ($item eq 'start') {
! 141: if ($starttime) {
! 142: if ($target eq 'web') {
! 143: $display = &Apache::lonlocal::locallocaltime($starttime);
! 144: } else {
! 145: $display = $starttime;
! 146: }
! 147: }
! 148: } elsif ($item eq 'end') {
! 149: if ($endtime) {
! 150: if ($target eq 'web') {
! 151: $display = &Apache::lonlocal::locallocaltime($endtime);
! 152: } else {
! 153: $display = $endtime;
! 154: }
! 155: }
! 156: }
1.1 raeburn 157: if ($target eq 'web') {
158: $message .= "<td>$display</td>";
159: } else {
160: $message .= "$display,";
161: }
162: }
163: } else {
164: if ($target eq 'web') {
165: $message .= '<td>'.$lt{'no'}.'<td>';
166: } else {
167: $message .= $lt{'no'}.',';
168: }
169: foreach my $item (@fields) {
170: if ($target eq 'web') {
171: $message .= '<td> </td>';
172: } else {
173: $message .= ',';
174: }
1.2 raeburn 175: }
176: }
177: if ($target eq 'web') {
178: $message .= &Apache::loncommon::end_data_table_row()."\n";
179: } else {
180: $message =~ s/,$//;
181: $message .= '&';
1.1 raeburn 182: }
183: }
184: if ($target eq 'web') {
185: $message .= &Apache::loncommon::end_data_table().'</fieldset>';
186: } else {
187: $message =~ s/\&$//;
188: }
189: $message .= "\n";
190: } else {
191: if ($target eq 'web') {
1.3 raeburn 192: $message .= "$server:error\n";
1.1 raeburn 193: } else {
1.3 raeburn 194: $message .= "$server:error\n";
1.1 raeburn 195: }
196: }
197: }
198: return $message;
199: }
200:
201: 1;
202:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>