Skip to content

Commit

Permalink
Item12180: Trap warnings if openssl is not available
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@16202 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Dec 13, 2012
1 parent 69d8238 commit bcf0427
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ sub showCSR {
return $this->ERROR("No CSR pending");
}

my $output = `openssl req -in $csrfile -batch -subject -text 2>&1`;
my $output;
{
no warnings 'exec';

$output = `openssl req -in $csrfile -batch -subject -text 2>&1`;
}
if ($?) {
return $this->ERROR("Operation failed")
. $this->FB_VALUE( '{ConfigureGUI}{SMIME}{InstallCert}', $output );
Expand Down Expand Up @@ -95,10 +100,15 @@ sub installCert {
&& $data =~ /^-----BEGIN CERTIFICATE-----/m
&& $data =~ /^-----END CERTIFICATE-----/m );

my $output = `openssl x509 -text 2>&1 <<~~~EOF---
my $output;
{
no warnings 'exec';

$output = `openssl x509 -text 2>&1 <<~~~EOF---
$data
~~~EOF---
`;
}
if ($?) {
return $this->ERROR("Operation failed")
. $this->FB_VALUE( '{ConfigureGUI}{SMIME}{InstallCert}', $output );
Expand Down Expand Up @@ -155,7 +165,11 @@ sub showCert {

my $output = "===== Certificate Details =====\n";

$output .= `openssl x509 -in $certfile -text -noout 2>&1`;
{
no warnings 'exec';

$output .= `openssl x509 -in $certfile -text -noout 2>&1`;
}
if ($?) {
return $this->ERROR("Operation failed on $certfile")
. $this->FB_VALUE( '{ConfigureGUI}{SMIME}{InstallCert}', $output );
Expand Down
25 changes: 15 additions & 10 deletions core/lib/Foswiki/Configure/Checkers/WebMasterName.pm
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,29 @@ CONFIG
);
$keyfile .= '.csr' unless ($self);
my $um = umask(0117);
my $output =
my ( $output, $keyoutput );
{
no warnings 'exec';

$output =
`openssl req -config $tmpfile -newkey rsa:2048 -keyout $keyfile $cmd -batch 2>&1`;
if ($?) {
umask($um);
return ( 0,
"Unable to create certificate"
. ( $self ? '' : ' request' )
. ": <pre>$output</pre>" );
}
if ($?) {
umask($um);
return ( 0,
"Unable to create certificate"
. ( $self ? '' : ' request' )
. ": <pre>$output</pre>" );
}

# Get key into the right format (RSA PRIVATE KEY, not ENCRYPTED PRIVATE KEY)
my $keyoutput =
`openssl rsa -in $keyfile -out $keyfile -des3 2>&1 <<+++EOF+++
$keyoutput =
`openssl rsa -in $keyfile -out $keyfile -des3 2>&1 <<+++EOF+++
$keypass
$keypass
$keypass
+++EOF+++
`;
}
umask($um);
if ($?) {
return ( 0, "Unable to convert private key: <pre>$keyoutput</pre>" );
Expand Down

0 comments on commit bcf0427

Please sign in to comment.