mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
When retrieving a public key for a certificate, private key, or signing request, write the certificate data out to a temp file instead of echoing it through a pipe. Fixes #8153
This commit is contained in:
parent
9038f44c7e
commit
b6dcbd646f
@ -603,20 +603,23 @@ function cert_get_publickey($str_crt, $decode = true, $type = "crt") {
|
||||
if ($decode) {
|
||||
$str_crt = base64_decode($str_crt);
|
||||
}
|
||||
$certfn = tempnam('/tmp', 'CGPK');
|
||||
file_put_contents($certfn, $str_crt);
|
||||
switch ($type) {
|
||||
case 'prv':
|
||||
exec("echo \"{$str_crt}\" | openssl pkey -pubout", $out);
|
||||
exec("/usr/bin/openssl pkey -in {$certfn} -pubout", $out);
|
||||
break;
|
||||
case 'crt':
|
||||
exec("echo \"{$str_crt}\" | openssl x509 -inform pem -noout -pubkey", $out);
|
||||
exec("/usr/bin/openssl x509 -in {$certfn} -inform pem -noout -pubkey", $out);
|
||||
break;
|
||||
case 'csr':
|
||||
exec("echo \"{$str_crt}\" | openssl req -inform pem -noout -pubkey", $out);
|
||||
exec("/usr/bin/openssl req -in {$certfn} -inform pem -noout -pubkey", $out);
|
||||
break;
|
||||
default:
|
||||
$out = array();
|
||||
break;
|
||||
}
|
||||
unlink($certfn);
|
||||
return implode("\n", $out);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user