diff --git a/src/CryptKey.php b/src/CryptKey.php index 9ec9202f..935461cc 100644 --- a/src/CryptKey.php +++ b/src/CryptKey.php @@ -14,7 +14,7 @@ namespace League\OAuth2\Server; class CryptKey { const RSA_KEY_PATTERN = - '/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----).+(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)$/s'; + '/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----).+(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)\s*$/s'; /** * @var string diff --git a/tests/CryptKeyTest.php b/tests/CryptKeyTest.php index ce3c8081..2a0b71ab 100644 --- a/tests/CryptKeyTest.php +++ b/tests/CryptKeyTest.php @@ -21,12 +21,6 @@ class CryptKeyTest extends \PHPUnit_Framework_TestCase $this->assertEquals('file://' . $keyFile, $key->getKeyPath()); $this->assertEquals('secret', $key->getPassPhrase()); - - $keyFile = __DIR__ . '/Stubs/private.key.crlf'; - $key = new CryptKey($keyFile, 'secret'); - - $this->assertEquals('file://' . $keyFile, $key->getKeyPath()); - $this->assertEquals('secret', $key->getPassPhrase()); } public function testKeyFileCreation() @@ -38,5 +32,13 @@ class CryptKeyTest extends \PHPUnit_Framework_TestCase 'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key', $key->getKeyPath() ); + + $keyContent = file_get_contents(__DIR__ . '/Stubs/private.key.crlf'); + $key = new CryptKey($keyContent); + + $this->assertEquals( + 'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key', + $key->getKeyPath() + ); } }