/** * Loads the certificate in the file given * * @param string $certificateFile the full path to the cert file. */ public function loadCertificateFile($certificateFile) { $certificate = File::getFileContents($certificateFile); if (!Certificate::hasValidStructure($certificate)) { throw new InvalidCertificateStructureException(sprintf('Could not find PEM encoded certificate in "%s"', $certificateFile)); } // capture the certificate contents without the delimiters preg_match(Certificate::CERTIFICATE_PATTERN, $certificate, $matches); $this->loadedKeys->add(X509::createFromCertificateData($matches[1])); }
/** * Loads a private key based on the configuration given. * * @param \SAML2\Configuration\PrivateKey $key * * @return \SAML2\Certificate\PrivateKey */ public function loadPrivateKey(PrivateKeyConfiguration $key) { $privateKey = File::getFileContents($key->getFilePath()); return PrivateKey::create($privateKey, $key->getPassPhrase()); }