1
Development and Code Review / Save configuration from code
« on: December 17, 2023, 05:22:12 pm »
Hello!
I need help! I write script, which generate user certificate by local CA, using internal functions. I have problem with saving this certificate in config.
Fragment:
var_dump returns correct configuration array with my new certificate. But I don't see it in web interface or in /conf/config.xml. In general log file I see:
But config not applying, also backup config file not exists.
What I'm doing wrong? Please, help!
I need help! I write script, which generate user certificate by local CA, using internal functions. I have problem with saving this certificate in config.
Fragment:
Code: [Select]
@require_once("config.inc");
@require_once("certs.inc");
@require_once('util.inc');
$certs = &config_read_array('cert');
const CAREFID='..........';
const CERT_DAYS=7;
$email='......';
$login='....';
cert_create($user_cert, CAREFID, 2048, CERT_DAYS, Array('emailAddress' => $email, 'ST'=>'State', 'O'=>'Org','L'=>'Location','CN'=>$login,'C'=>'CN'), 'SHA256');
$user_cert['descr'] = 'certificate-'.$login;
$user_cert['refid'] = uniqid();
$certs[]=$user_cert;
var_dump(write_config('Generate webmail cert for '.$login));
var_dump returns correct configuration array with my new certificate. But I don't see it in web interface or in /conf/config.xml. In general log file I see:
Code: [Select]
2023-12-17T18:57:16 Notice configctl event @ 1702828636.28 exec: system event config_changed
2023-12-17T18:57:16 Notice configctl event @ 1702828636.28 msg: Dec 17 18:57:16 hostname.localdomain config[30917]: config-event: new_config /conf/backup/config-1702828636.2734.xml
But config not applying, also backup config file not exists.
What I'm doing wrong? Please, help!