Ejemplo n.º 1
0
 /**
  * @test
  *
  * @uses Lcobucci\JWT\Signer\Key
  *
  * @covers Lcobucci\JWT\Signer\Keychain::getPublicKey
  */
 public function getPublicKeyShouldReturnAValidResource()
 {
     $keychain = new Keychain();
     $key = $keychain->getPublicKey('testing');
     $this->assertInstanceOf(Key::class, $key);
     $this->assertAttributeEquals('testing', 'content', $key);
     $this->assertAttributeEquals(null, 'passphrase', $key);
 }
Ejemplo n.º 2
0
 private function prepareKeychain($configuration)
 {
     try {
         $keychainPath = isset($configuration['Server']['keychain']) ? $configuration['Server']['keychain'] : static::DEFAULT_SERVER_KEYCHAIN;
         $this->keychain = new Keychain($keychainPath, $this);
         $serverPrivateKey = isset($configuration['Server']['privateKey']) ? $configuration['Server']['privateKey'] : static::DEFAULT_SERVER_PRIVATE_KEY;
         if (!$this->keychain->verifyKey($serverPrivateKey)) {
             throw new \InvalidArgumentException("Failed to verify server private key at {$serverPrivateKey}");
         }
         $this->serverPrivateKey = $serverPrivateKey;
     } catch (\Exception $e) {
         //Keychain exceptions can contain sensitive information
         throw new \RuntimeException("Failed to initialize keychain", 0, $e);
     }
 }