From b6dcbd646feb9c7197b4e94a6031b69c2113d679 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 1 Dec 2017 12:41:56 -0500 Subject: [PATCH] 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 --- src/etc/inc/certs.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/certs.inc b/src/etc/inc/certs.inc index c2a2a6c675..070043416b 100644 --- a/src/etc/inc/certs.inc +++ b/src/etc/inc/certs.inc @@ -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); }