[LON-CAPA-cvs] cvs: loncom /configuration SSL.pm
raeburn
raeburn at source.lon-capa.org
Sun Aug 7 00:18:21 EDT 2016
raeburn Sun Aug 7 04:18:21 2016 EDT
Modified files:
/loncom/configuration SSL.pm
Log:
- Check start and end date/times for certificates.
- Display date as "Expired" or "Future validity" unless currently valid.
- For web target use LON-CAPA's lonlocal::locallocaltime() to format
start and end dates for valid certificates.
Index: loncom/configuration/SSL.pm
diff -u loncom/configuration/SSL.pm:1.3 loncom/configuration/SSL.pm:1.4
--- loncom/configuration/SSL.pm:1.3 Mon Aug 1 18:03:53 2016
+++ loncom/configuration/SSL.pm Sun Aug 7 04:18:21 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Checksum installed LON-CAPA modules and some configuration files
#
-# $Id: SSL.pm,v 1.3 2016/08/01 18:03:53 raeburn Exp $
+# $Id: SSL.pm,v 1.4 2016/08/07 04:18:21 raeburn Exp $
#
# The LearningOnline Network with CAPA
#
@@ -35,6 +35,8 @@
use Apache::lonnet();
use Apache::loncommon();
use Apache::lonhtmlcommon();
+use DateTime;
+use DateTime::Format::x509;
use LONCAPA;
sub print_certstatus {
@@ -57,6 +59,8 @@
'host' => 'Connections Certificate',
'hostname' => 'Replication Certificate',
'ca' => 'LON-CAPA CA Certificate',
+ 'expired' => 'Expired',
+ 'future' => 'Future validity',
);
my @files = qw(key host hostname ca);
my @fields = qw(status cn start end alg size email);
@@ -83,23 +87,79 @@
$message .= $file.'=';
}
if (ref($hashref->{$file}) eq 'HASH') {
+ my ($starttime,$endtime,$dateinvalid);
if ($target eq 'web') {
$message .= '<td>'.$lt{'yes'}.'</td>';
} else {
$message .= $lt{'yes'}.',';
}
+ unless ($file eq 'key') {
+ if ($hashref->{$file}->{'end'} ne '') {
+ my $dt = DateTime::Format::x509->parse_datetime($hashref->{$file}->{'end'});
+ if (ref($dt)) {
+ $endtime = $dt->epoch;
+ if ($endtime < time) {
+ $dateinvalid = $lt{'expired'};
+ }
+ }
+ }
+ if ($hashref->{$file}->{'start'} ne '') {
+ my $dt = DateTime::Format::x509->parse_datetime($hashref->{$file}->{'start'});
+ if (ref($dt)) {
+ $starttime = $dt->epoch;
+ if ($starttime > time) {
+ unless ($dateinvalid) {
+ $dateinvalid = $lt{'future'};
+ }
+ }
+ }
+ }
+ }
foreach my $item (@fields) {
my $display = $hashref->{$file}->{$item};
- if ($target eq 'web') {
- if ($item eq 'status') {
- $display = &Apache::lonhtmlcommon::confirm_success($display);
+ if ($item eq 'status') {
+ if ($file eq 'key') {
+ if ($display =~ /ok$/) {
+ if ($target eq 'web') {
+ $display = &Apache::lonhtmlcommon::confirm_success($display);
+ }
+ }
+ } elsif ($file eq 'ca') {
+ if ($dateinvalid) {
+ $display = $dateinvalid;
+ } elsif ($target eq 'web') {
+ $display = &Apache::lonhtmlcommon::confirm_success($display);
+ }
+ } elsif ($display =~ /^ok/) {
+ if ($dateinvalid) {
+ $display = $dateinvalid;
+ } elsif ($target eq 'web') {
+ $display = &Apache::lonhtmlcommon::confirm_success($display);
+ }
}
+ } elsif ($item eq 'start') {
+ if ($starttime) {
+ if ($target eq 'web') {
+ $display = &Apache::lonlocal::locallocaltime($starttime);
+ } else {
+ $display = $starttime;
+ }
+ }
+ } elsif ($item eq 'end') {
+ if ($endtime) {
+ if ($target eq 'web') {
+ $display = &Apache::lonlocal::locallocaltime($endtime);
+ } else {
+ $display = $endtime;
+ }
+ }
+ }
+ if ($target eq 'web') {
$message .= "<td>$display</td>";
} else {
$message .= "$display,";
}
}
-
} else {
if ($target eq 'web') {
$message .= '<td>'.$lt{'no'}.'<td>';
More information about the LON-CAPA-cvs
mailing list