Allow simple uploading of chained cert file
authorJamie Cameron <jcameron@webmin.com>
Mon, 13 Jun 2011 23:43:36 +0000 (16:43 -0700)
committerJamie Cameron <jcameron@webmin.com>
Mon, 13 Jun 2011 23:43:36 +0000 (16:43 -0700)
webmin/CHANGELOG
webmin/edit_ssl.cgi
webmin/lang/en
webmin/savekey.cgi

index 619cb7c..c8bcb54 100644 (file)
@@ -107,3 +107,4 @@ Added the Sending Email page which controls how Webmin itself sends messages.
 Added fields to the Index Page Options page to control the display of Webmin and module updates.
 Moved settings related to Webmin's built-in webserver to the new Web Server Options page.
 The client-side expiry time for static files served by Webmin can now be configured on the Web Server Options page, and can be customized on a per-file basis.
+A chained certificate file supplied by a CA can now be easily uploaded using the Upload certificate tab on the SSL Encryption page.
index 349170b..0ee4751 100755 (executable)
@@ -152,7 +152,7 @@ print &ui_form_start("savekey.cgi", "form-data");
 print &ui_table_start($text{'ssl_saveheader'}, undef, 2);
 
 print &ui_table_row($text{'ssl_privkey'},
-                   &ui_textarea("key", undef, 7, 60)."<br>\n".
+                   &ui_textarea("key", undef, 7, 70)."<br>\n".
                    "<b>$text{'ssl_upload'}</b>\n".
                    &ui_upload("keyfile"));
 
@@ -160,10 +160,19 @@ print &ui_table_row($text{'ssl_privcert'},
                    &ui_radio("cert_def", 1,
                        [ [ 1, $text{'ssl_same'} ],
                          [ 0, $text{'ssl_below'} ] ])."<br>\n".
-                   &ui_textarea("cert", undef, 7, 60)."<br>\n".
+                   &ui_textarea("cert", undef, 7, 70)."<br>\n".
                    "<b>$text{'ssl_upload'}</b>\n".
                    &ui_upload("certfile"));
 
+print &ui_table_row($text{'ssl_privchain'},
+                   &ui_radio("chain_def", 1,
+                       [ [ 1, $miniserv{'extracas'} ? $text{'ssl_leavechain'}
+                                                    : $text{'ssl_nochain'} ],
+                         [ 0, $text{'ssl_below'} ] ])."<br>\n".
+                   &ui_textarea("chain", undef, 7, 70)."<br>\n".
+                   "<b>$text{'ssl_upload'}</b>\n".
+                   &ui_upload("chainfile"));
+
 print &ui_table_end();
 print &ui_form_end([ [ "save", $text{'save'} ] ]);
 print &ui_tabs_end_tab();
index 4d3bf9c..b5e5bc1 100644 (file)
@@ -352,6 +352,9 @@ ssl_eversion=Missing or invalid version number
 ssl_saveheader=Upload existing key
 ssl_privkey=Private key text
 ssl_privcert=Certificate text
+ssl_privchain=Chained certificate text
+ssl_nochain=No chained certificate
+ssl_leavechain=Use existing chained certificate
 ssl_upload=Or from upload file
 ssl_same=Combined with private key
 ssl_below=Entered below ..
@@ -814,9 +817,11 @@ savekey_err=Failed to save new key
 savekey_ekey=Missing or invalid PEM format key
 savekey_ecert=Missing or invalid PEM format certificate
 savekey_ecert2=Missing or invalid PEM format key and certificate
+savekey_echain=Missing or invalid PEM format chained certificate
 savekey_title=Upload Existing Key
 savekey_done2=The supplied SSL key has been saved in $1, and the certificate in $2.
 savekey_done=The supplied SSL key and certitifcate have been saved in the file $1.
+savekey_done3=The supplied chained SSL certificate has been saved in the file $1.
 
 cache_title=Cached URLs
 cache_search=Find URLs containing:
index f6bcaa6..2de037a 100755 (executable)
@@ -22,6 +22,13 @@ else {
        $key =~ /BEGIN CERTIFICATE/ &&
          $key =~ /END CERTIFICATE/ || &error($text{'savekey_ecert2'});
        }
+if (!$in{'chain_def'}) {
+       # Make sure chained cert is valid
+       $chain = $in{'chain'} || $in{'chainfile'};
+       $chain =~ s/\r//g;
+       $chain =~ /BEGIN CERTIFICATE/ &&
+         $chain =~ /END CERTIFICATE/ || &error($text{'savekey_echain'});
+       }
 
 # Save config and key file
 &lock_file($ENV{'MINISERV_CONFIG'});
@@ -43,6 +50,15 @@ else {
        &close_tempfile(CERT);
        &unlock_file($miniserv{'certfile'});
        }
+if (!$in{'chain_def'}) {
+       $miniserv{'extracas'} = "$config_directory/miniserv.chain"
+               if (!$miniserv{'extracas'} || $miniserv{'extracas'} =~ /\s/);
+       &lock_file($miniserv{'extracas'});
+       &open_tempfile(CERT, ">$miniserv{'extracas'}");
+       &print_tempfile(CERT, $chain);
+       &close_tempfile(CERT);
+       &unlock_file($miniserv{'extracas'});
+       }
 &put_miniserv_config(\%miniserv);
 &unlock_file($ENV{'MINISERV_CONFIG'});
 
@@ -56,6 +72,9 @@ if ($miniserv{'certfile'}) {
 else {
        print &text('savekey_done', "<tt>$miniserv{'keyfile'}</tt>"),"<p>\n";
        }
+if (!$in{'chain_def'}) {
+       print &text('savekey_done3', "<tt>$miniserv{'extracas'}</tt>"),"<p>\n";
+       }
 
 &ui_print_footer("", $text{'index_return'});