Make missing / invalid cert file format error clearer

This commit is contained in:
Jamie Cameron
2018-02-25 12:27:42 -08:00
parent c7ea4e04e8
commit 5d68d0071d
2 changed files with 10 additions and 6 deletions

View File

@@ -338,8 +338,10 @@ ssl_extracasdef=Same as global SSL settings
ssl_extracasnone=None for this IP address
ssl_extracasbelow=Entered below ..
ssl_err=Failed to save SSL options
ssl_ekey=The SSL private key file $1 does not exist or does not contain a PEM format key
ssl_ecert=The SSL certificate file $1 does not exist or does not contain a PEM format certificate
ssl_ekey=The SSL private key file $1 does not exist
ssl_ekey2=The SSL private key file $1 does not contain a PEM format key
ssl_ecert=The SSL certificate file $1 does not exist
ssl_ecert2=The SSL certificate file $1 does not contain a PEM format certificate
ssl_newkey=This form can be used to create a new SSL key and certificate for your Webmin server.
ssl_newcsr=This form can be used to create a new SSL key and certificate signing request (CSR) for your Webmin server. The CSR must be signed by a certificate authority (CA) before it can be used.
ssl_hole=Because you are currently using the default Webmin SSL key that everyone has access to, you should generate a new key immediately. Otherwise your SSL connection is not secure!

View File

@@ -1039,15 +1039,17 @@ line.
sub validate_key_cert
{
my ($keyfile, $certfile) = @_;
-r $keyfile || return &error(&text('ssl_ekey', $keyfile));
my $key = &read_file_contents($keyfile);
$key =~ /BEGIN (RSA | EC )?PRIVATE KEY/i ||
&error(&text('ssl_ekey', $keyfile));
&error(&text('ssl_ekey2', $keyfile));
if (!$certfile) {
$key =~ /BEGIN CERTIFICATE/ || &error(&text('ssl_ecert', $keyfile));
$key =~ /BEGIN CERTIFICATE/ || &error(&text('ssl_ecert2', $keyfile));
}
else {
my $cert = &read_file_contents($_[1]);
$cert =~ /BEGIN CERTIFICATE/ || &error(&text('ssl_ecert', $certfile));
-r $certfile || return &error(&text('ssl_ecert', $certfile));
my $cert = &read_file_contents($certfile);
$cert =~ /BEGIN CERTIFICATE/ || &error(&text('ssl_ecert2', $certfile));
}
}