File:
[LON-CAPA] /
loncom /
configuration /
SSL.pm
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Mon Jul 25 19:50:16 2016 UTC (8 years, 8 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Use Server Name Indication (SNI) and SSL when replicating content from
/raw/.
- Domain status screen has link to show status of LON-CAPA SSL certificates.
- "SSL" domain config for (a) "internal" LON-CAPA SSL connection to servers/VMs
in other domain, (b) Replication of domain's resources to other domains.
- Replication can use name-based virtual hosts with SSL, with verification of
client certificate (cert: /home/httpd/lonCerts/lonhostnamecert.pem, signed
by LON-CAPA CA, with Common Name of internal-<server hostname>, same IP address
as server hostname).
# The LearningOnline Network with CAPA
# Checksum installed LON-CAPA modules and some configuration files
#
# $Id: SSL.pm,v 1.1 2016/07/25 19:50:16 raeburn Exp $
#
# The LearningOnline Network with CAPA
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package LONCAPA::SSL;
use strict;
use lib '/home/httpd/lib/perl/';
use Apache::lonlocal();
use Apache::lonnet();
use Apache::loncommon();
use Apache::lonhtmlcommon();
use LONCAPA;
sub print_certstatus {
my ($servers,$target,$context) = @_;
return unless (ref($servers) eq 'HASH');
my $message;
my %lt = &Apache::lonlocal::texthash (
'file' => 'File',
'avai' => 'Available',
'yes' => 'Yes',
'no' => 'No',
'cn' => 'Common Name',
'start' => 'Valid From',
'end' => 'Valid To',
'alg' => 'Signature Algorithm',
'size' => 'Public Key Size',
'status' => 'Status',
'email' => 'E-mail',
'key' => 'Private Key',
'host' => 'Connections Certificate',
'hostname' => 'Replication Certificate',
'ca' => 'LON-CAPA CA Certificate',
);
my @files = qw(key host hostname ca);
my @fields = qw(status cn start end alg size email);
foreach my $server (sort(keys(%{$servers}))) {
my $hostname = &Apache::lonnet::hostname($server);
my ($result,$hashref) = &Apache::lonnet::get_servercerts_info($server,$context);
if ($result eq 'ok' && ref($hashref) eq 'HASH') {
if ($target eq 'web') {
$message .= "<fieldset><legend>$hostname ($server)</legend>".
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row()."\n";
foreach my $item ('file','avai',@fields) {
$message .= '<th>'.$lt{$item}.'</th>';
}
$message .= &Apache::loncommon::end_data_table_header_row()."\n";
} else {
$message .= $server.':';
}
foreach my $file (@files) {
if ($target eq 'web') {
$message .= &Apache::loncommon::start_data_table_row()."\n".
'<td>'.$lt{$file}.'</td>';
} else {
$message .= $file.'=';
}
if (ref($hashref->{$file}) eq 'HASH') {
if ($target eq 'web') {
$message .= '<td>'.$lt{'yes'}.'</td>';
} else {
$message .= $lt{'yes'}.',';
}
foreach my $item (@fields) {
my $display = $hashref->{$file}->{$item};
if ($target eq 'web') {
if ($item eq 'status') {
$display = &Apache::lonhtmlcommon::confirm_success($display);
}
$message .= "<td>$display</td>";
} else {
$message .= "$display,";
}
}
} else {
if ($target eq 'web') {
$message .= '<td>'.$lt{'no'}.'<td>';
} else {
$message .= $lt{'no'}.',';
}
foreach my $item (@fields) {
if ($target eq 'web') {
$message .= '<td> </td>';
} else {
$message .= ',';
}
}
if ($target eq 'web') {
$message .= &Apache::loncommon::end_data_table_row()."\n";
} else {
$message =~ s/,$//;
$message .= '&';
}
}
}
if ($target eq 'web') {
$message .= &Apache::loncommon::end_data_table().'</fieldset>';
} else {
$message =~ s/\&$//;
}
$message .= "\n";
} else {
if ($target eq 'web') {
$message .= "$server error\n";
} else {
$message .= "$server error\n";
}
}
}
return $message;
}
1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>