summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/certs.inc
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2017-04-17 20:40:58 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2017-04-17 20:40:58 +0200
commit6d6ba6601997908dcea91b26feb07b760ad7105d (patch)
treec9dd40e2488bb4ce9136561ce4e380882f84e264 /src/etc/inc/certs.inc
parent1746c5cea5f1317b4cdfcbff2e14366c93f3aea5 (diff)
downloadpfsense-6d6ba6601997908dcea91b26feb07b760ad7105d.zip
pfsense-6d6ba6601997908dcea91b26feb07b760ad7105d.tar.gz
certificate manager, allow importing of ECC certificates, change multiple 'if' to 'switch'
Diffstat (limited to 'src/etc/inc/certs.inc')
-rw-r--r--src/etc/inc/certs.inc27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/etc/inc/certs.inc b/src/etc/inc/certs.inc
index 98059db..0eb70cf 100644
--- a/src/etc/inc/certs.inc
+++ b/src/etc/inc/certs.inc
@@ -546,20 +546,21 @@ function cert_get_publickey($str_crt, $decode = true, $type = "crt") {
if ($decode) {
$str_crt = base64_decode($str_crt);
}
- $publickey = "";
- if ($type == "prv") {
- exec("echo \"{$str_crt}\" | openssl pkey -pubout", $out);
- $publickey = implode("\n", $out);
- }
- if ($type == "crt") {
- exec("echo \"{$str_crt}\" | openssl x509 -inform pem -noout -pubkey", $out);
- $publickey = implode("\n", $out);
- }
- if ($type == "csr") {
- exec("echo \"{$str_crt}\" | openssl req -inform pem -noout -pubkey", $out);
- $publickey = implode("\n", $out);
+ switch ($type) {
+ case 'prv':
+ exec("echo \"{$str_crt}\" | openssl pkey -pubout", $out);
+ break;
+ case 'crt':
+ exec("echo \"{$str_crt}\" | openssl x509 -inform pem -noout -pubkey", $out);
+ break;
+ case 'csr':
+ exec("echo \"{$str_crt}\" | openssl req -inform pem -noout -pubkey", $out);
+ break;
+ default:
+ $out = array();
+ break;
}
- return $publickey;
+ return implode("\n", $out);
}
function cert_get_purpose($str_crt, $decode = true) {
OpenPOWER on IntegriCloud