Experiment with accountkeys per customer

Signed-off-by: Florian Aders <eleras@froxlor.org>
This commit is contained in:
Florian Aders
2016-01-30 13:06:42 +01:00
parent 2e7dd6f212
commit 67df9dbf6b
4 changed files with 16 additions and 8 deletions

View File

@@ -47,10 +47,10 @@ class lescript
$this->client = new Client($this->ca);
}
public function initAccount()
public function initAccount($certrow)
{
// Let's see if we have the private accountkey
$this->accountKey = Settings::Get('system.leprivatekey');
$this->accountKey = $certrow['leprivatekey'];
if (!$this->accountKey || $this->accountKey == 'unset') {
// generate and save new private key for account
@@ -58,8 +58,10 @@ class lescript
$this->log('Starting new account registration');
$keys = $this->generateKey();
Settings::Set('system.leprivatekey', $keys['private']);
Settings::Set('system.lepublickey', $keys['public']);
$upd_stmt = Database::prepare("
UPDATE `".TABLE_PANEL_CUSTOMERS."` SET `lepublickey` = :public AND `leprivatekey` = :private WHERE `customerid` = :customerid;
");
Database::pexecute($upd_stmt, array('public' => $keys['public'], 'private' => $keys['private'], 'customerid' => $certrow['customerid']));
$this->accountKey = $keys['private'];
$this->postNewReg();
$this->log('New account certificate registered');