Ejemplo n.º 1
0
 /**
  * @param  string $publicKeyFile /full/path/to/the/public/key
  * @return SAML2_Certificate_X509
  */
 public function loadPublicKeyFromFile($publicKeyFile)
 {
     $this->publicKeyLoader->loadCertificateFile($publicKeyFile);
     $keyCollection = $this->publicKeyLoader->getKeys();
     $publicKey = $keyCollection->getOnlyElement();
     // remove it from the collection so we can reuse the publicKeyLoader for consecutive signing
     $keyCollection->remove($publicKey);
     return $publicKey;
 }
Ejemplo n.º 2
0
 /**
  * @group certificate
  *
  * @test
  */
 public function loading_a_certificate_from_file_creates_a_key()
 {
     $file = dirname(__FILE__) . '/File/example.org.crt';
     $this->keyLoader->loadCertificateFile($file);
     $loadedKeys = $this->keyLoader->getKeys();
     $loadedKey = $loadedKeys->get(0);
     $fileContents = file_get_contents($file);
     preg_match(SAML2_Utilities_Certificate::CERTIFICATE_PATTERN, $fileContents, $matches);
     $expected = preg_replace('~\\s+~', '', $matches[1]);
     $this->assertTrue($this->keyLoader->hasKeys());
     $this->assertCount(1, $loadedKeys);
     $this->assertEquals($expected, $loadedKey['X509Certificate']);
 }