[LON-CAPA-cvs] cvs: loncom / CrGenerate.pl

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 29 Jun 2004 11:32:07 -0000


foxr		Tue Jun 29 07:32:07 2004 EDT

  Modified files:              
    /loncom	CrGenerate.pl 
  Log:
  Implement the ReadConfig sub.  This sub parses the apache config files
  for the PerlSetVars and extracts:
  
  SSLProgram               - Path to the SSL utility command (openssl e.g.).
  lonCertificateDirectory  - Where certificates will be installed.
  lonnetPrivateKey         - Name of the private key file to produce.
  SSLEmail                 - Email address of the certificate administrator.
  
  
  
Index: loncom/CrGenerate.pl
diff -u loncom/CrGenerate.pl:1.2 loncom/CrGenerate.pl:1.3
--- loncom/CrGenerate.pl:1.2	Tue Jun 29 07:13:08 2004
+++ loncom/CrGenerate.pl	Tue Jun 29 07:32:06 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # CrGenerate - Generate a loncapa certificate request.
 #
-# $Id: CrGenerate.pl,v 1.2 2004/06/29 11:13:08 foxr Exp $
+# $Id: CrGenerate.pl,v 1.3 2004/06/29 11:32:06 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,6 +60,8 @@
 my $Passphrase="loncapawhatever"; # Initial passphrase for keyfile
 my $RequestEmail;		  # Email address of loncapa cert admin.
 
+
+
 #   Debug/log support:
 #
 my $DEBUG = 1;			# 1 for on, 0 for off.
@@ -77,8 +79,62 @@
     }
 }
 
+#
+#   Read the LonCAPA web config files to get the values of the 
+#   configuration global variables we need:
+# Implicit inputs:
+#   loncapa.conf   - configuration file to read (user specific).
+# Implicit outputs (see global variables section):
+#   SSLCommand,
+#   CertificateDirectory
+#   KeyfileName
+#   RequestEmail
+# Side-Effects:
+#   Exit with error if cannot complete.
+#
+sub ReadConfig {
+
+    Debug("Reading configuration");
+    my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');
+    
+    # Name of the SSL Program
+
+    if($perlvarref->{SSLProgram}) {
+	$SSLCommand = $perlvarref->{SSLProgram};
+	Debug("SSL Command: $SSLCommand");
+    }
+    else {
+	die "Unable to read the SSLCommand configuration option\n";
+    }
+
+    # Where the certificates, and host key are installed:
 
-sub ReadConfig {}
+    if($perlvarref->{lonCertificateDirectory}) {
+	$CertificateDirectory = $perlvarref->{lonCertificateDirectory};
+	Debug("Local certificate Directory: $CertificateDirectory");
+    }
+    else {
+	die "Unable to read SSLDirectory configuration option\n";
+    }
+    # The name of the host key file (to be installed in SSLDirectory).
+    #
+    if($perlvarref->{lonnetPrivateKey}) {
+	$KeyFilename  = $perlvarref->{lonnetPrivateKey};
+	Debug("Private key will be installed as $KeyFilename");
+    } 
+    else {
+	die "Unable to read lonnetPrivateKey conrig paraemter\n";
+    }
+    #  The email address to which the certificate request is sent:
+
+    if($perlvarref->{SSLEmail}) {
+	$RequestEmail = $perlvarref->{SSLEmail};
+	Debug("Certificate request will be sent to $RequestEmail");
+    }
+    else {
+	die "Could not read SSLEmail coniguration key";
+    }
+}
 sub GenerateRequest {}
 sub InstallKey {}
 sub MailRequest {}