diff --git a/genkey.pl b/genkey.pl index 8466f8d..315253d 100644 --- a/genkey.pl +++ b/genkey.pl @@ -121,10 +121,11 @@ my $test_mode = ''; my $genreq_mode = ''; my $ca_mode = ''; my $cert_days = 30; -my $nss=''; -my $debug=''; +my $nss =''; +my $debug =''; my $modNssDbDir = ''; -my $nickname = ''; +my $nssNickname = ''; +my $nssDBPrefix = ''; GetOptions('test|t' => \$test_mode, 'genreq' => \$genreq_mode, 'days=i' => \$cert_days, @@ -132,8 +133,7 @@ GetOptions('test|t' => \$test_mode, 'debug|d'=> \$debug, 'makeca' => \$ca_mode) or usage(); usage() unless @ARGV != 0; -$skip_random = $test_mode; -$overwrite_key = $test_mode; +$overwrite_key = $test_mode && !$nss; $servername = $ARGV[0]; $randfile = $ssltop."/.rand.".$$; $tmpPasswordFile = ''; # none has been created yet @@ -170,7 +170,7 @@ if (!$genreq_mode && -f $keyfile && !$overwrite_key) { exit 1; } -# For mod_nss we need the database and nickname set +# For mod_nss we need these variables set if ($nss) { # the configuration file is required if (!nssconfigFound()) { @@ -182,7 +182,8 @@ if ($nss) { } $modNssDbDir = getModNSSDatabase(); - $nickname = getNickname(); + $nssNickname = getNSSNickname(); + $nssDBPrefix = getNSSDBPrefix(); } ###################################################################### @@ -217,7 +218,7 @@ if ($genreq_mode) { keyPasswordWindow, genCACertWindow, ); - $doingwhat="CA key generation"; + $doingwhat="CA cert generation"; } else { @windows = (welcomeWindow, getkeysizeWindow, @@ -227,12 +228,11 @@ if ($genreq_mode) { whichCAWindow, keyPasswordWindow, genReqWindow, - genCertWindow, genReqWindow, genCertWindow, ### @EXTRA@ ### Leave this comment here. ); - $doingwhat="testing request and cert generation"; + $doingwhat="testing CSR and cert generation"; } my $screen = 0; @@ -337,17 +337,32 @@ sub getModNSSDatabase { } # Returns the rsa server name. -sub getNickname { +sub getNSSNickname { # Extract the value from the mod_nss configuration file. my $cmd ='/usr/bin/gawk \'/^NSSNickname/ { print $2 }\'' . " $nssconf"; - my $nicknamefile = "nickname"; + my $nicknamefile = "nssnickname"; system("$cmd > $nicknamefile"); open(NICK, "<$nicknamefile"); my $nickname = ; unlink($nicknamefile); + my $prefix = $nss ? "modnss.test." : "modssl.test"; + $nickname = $prefix . $nickname if $debug; + return $nickname; +} - return "test-".$nickname; +# Returns the nss database prefix +sub getNSSDBPrefix { + + # Extract the value from the mod_nss configuration file. + my $cmd ='/usr/bin/gawk \'/^NSSDBPrefix/ { print $2 }\'' . " $nssconf"; + my $prefixfile = "dbprefix"; + system("$cmd > $prefixfile"); + open(PREFIX, "<$prefixfile"); + my $prefix = ; + unlink($prefixfile); + + return $prefix; } # Erases and deletes the password file @@ -517,7 +532,11 @@ EOT sub welcomeWindow() { my $name = $servername; - my $where = $nss ? $modNssDbDir : "$ssltop/private/$name.key"; + my $where_key = $nss + ? $modNssDbDir."key3.db" : "$ssltop/private/$name.key"; + my $where_cert = $nss + ? $modNssDbDir."cert8.db" : "$ssltop/certs/$name.cert"; + my $what = $nss ? "directory" : "file"; my $message = <