diff options
author | PiBa-NL <pba_2k3@yahoo.com> | 2014-02-16 21:26:05 +0100 |
---|---|---|
committer | PiBa-NL <pba_2k3@yahoo.com> | 2014-02-16 21:26:05 +0100 |
commit | 46ea54e1b550fcac78752b70f3419a0bf1eb7ec4 (patch) | |
tree | b61e613f61fbdaa7f24aab371b47ae1fa4a16071 | |
parent | b07bce1a7b918ade438851b60a25372abdef7908 (diff) | |
download | pfsense-packages-46ea54e1b550fcac78752b70f3419a0bf1eb7ec4.tar.gz pfsense-packages-46ea54e1b550fcac78752b70f3419a0bf1eb7ec4.tar.bz2 pfsense-packages-46ea54e1b550fcac78752b70f3419a0bf1eb7ec4.zip |
haproxy-devel, add missing function haproxy_find_create_certificate(..)
-rw-r--r-- | config/haproxy-devel/haproxy.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc index bcadcfd9..20f6847c 100644 --- a/config/haproxy-devel/haproxy.inc +++ b/config/haproxy-devel/haproxy.inc @@ -1233,4 +1233,25 @@ function haproxy_escape_acl_name($aclname) { return preg_replace_callback('([^A-Za-z0-9\._\-\:])', function($match){return "_".dechex(ord($match[0]));}, $aclname); } +function haproxy_find_create_certificate($certificatename) { + global $g; + $cert = lookup_cert_by_name($certificatename); + if (is_array($cert)) + return $cert; + global $config; + $a_cert =& $config['cert']; + $cert = array(); + $cert['refid'] = uniqid(); + $cert['descr'] = gettext($certificatename); + mwexec("/usr/local/bin/openssl genrsa 1024 > {$g['tmp_path']}/ssl.key"); + mwexec("/usr/local/bin/openssl req -new -x509 -nodes -sha256 -days 2000 -key {$g['tmp_path']}/ssl.key > {$g['tmp_path']}/ssl.crt"); + $crt = file_get_contents("{$g['tmp_path']}/ssl.crt"); + $key = file_get_contents("{$g['tmp_path']}/ssl.key"); + unlink("{$g['tmp_path']}/ssl.key"); + unlink("{$g['tmp_path']}/ssl.crt"); + cert_import($cert, $crt, $key); + $a_cert[] = $cert; + return $cert; +} + ?> |