mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
OpenVPN export, add export_pkcs12() to BaseExporter for easy pkcs12 generation. for https://github.com/opnsense/core/issues/2787
Example usage (from inherited object): $p12 = $this->export_pkcs12($this->config['client_crt'], $this->config['client_prv'], $this->config['p12_password']);
This commit is contained in:
parent
04df3de895
commit
d001f34479
@ -44,4 +44,19 @@ abstract class BaseExporter
|
||||
{
|
||||
$this->config = $conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $crt X.509 certificate
|
||||
* @param string $prv PEM formatted private key
|
||||
* @param string $pass password
|
||||
* @return string pkcs12
|
||||
*/
|
||||
protected function export_pkcs12($crt, $prv, $pass="")
|
||||
{
|
||||
$p12 = null;
|
||||
$crt = openssl_x509_read($crt);
|
||||
$prv = openssl_get_privatekey($prv);
|
||||
openssl_pkcs12_export($crt, $p12, $prv, $pass);
|
||||
return $p12;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user