AcmePhp\Cli\Repository\Repository::storeAccountKeyPair PHP Method

storeAccountKeyPair() public method

public storeAccountKeyPair ( KeyPair $keyPair )
$keyPair AcmePhp\Ssl\KeyPair
    public function storeAccountKeyPair(KeyPair $keyPair)
    {
        try {
            $this->save('private/_account/public.pem', $this->serializer->serialize($keyPair->getPublicKey(), PemEncoder::FORMAT));
            $this->save('private/_account/private.pem', $this->serializer->serialize($keyPair->getPrivateKey(), PemEncoder::FORMAT));
        } catch (\Exception $e) {
            throw new AcmeCliException('Storing of account key pair failed', $e);
        }
    }

Usage Example

 public function testLoadAccountKeyPair()
 {
     $keyPair = new KeyPair(new PublicKey("public\n"), new PrivateKey("private\n"));
     $this->assertFalse($this->repository->hasAccountKeyPair());
     $this->repository->storeAccountKeyPair($keyPair);
     $this->assertTrue($this->repository->hasAccountKeyPair());
     $this->assertEquals($keyPair, $this->repository->loadAccountKeyPair());
 }