Skip to content

Commit

Permalink
Merge branch 'feature/openssl-ecdsa-certificate-compatibility' into 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lcobucci committed Aug 13, 2016
2 parents 3405ec0 + 2459a86 commit 7668cb0
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 35 deletions.
69 changes: 35 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Signer/Ecdsa/KeyParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function getKeyContent(Key $key, $header)
$match = null;

preg_match(
'/^[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}$/',
'/[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}/',
str_replace([PHP_EOL, "\n", "\r"], '', $key->getContent()),
$match
);
Expand Down
30 changes: 30 additions & 0 deletions test/functional/EcdsaTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,36 @@ public function verifyShouldReturnTrueWhenKeyIsRight(Token $token)
$this->assertTrue($token->verify($this->signer, static::$ecdsaKeys['public1']));
}

/**
* @test
*
* @covers Lcobucci\JWT\Builder
* @covers Lcobucci\JWT\Token
* @covers Lcobucci\JWT\Signature
* @covers Lcobucci\JWT\Claim\Factory
* @covers Lcobucci\JWT\Claim\Basic
* @covers Lcobucci\JWT\Parsing\Encoder
* @covers Lcobucci\JWT\Signer\Key
* @covers Lcobucci\JWT\Signer\BaseSigner
* @covers Lcobucci\JWT\Signer\Ecdsa
* @covers Lcobucci\JWT\Signer\Ecdsa\KeyParser
* @covers Lcobucci\JWT\Signer\Ecdsa\Sha256
*/
public function everythingShouldWorkWithAKeyWithParams()
{
$user = (object) ['name' => 'testing', 'email' => '[email protected]'];

$token = (new Builder())->setId(1)
->setAudience('http://client.abc.com')
->setIssuer('http://api.abc.com')
->set('user', $user)
->setHeader('jki', '1234')
->sign($this->signer, static::$ecdsaKeys['private-params'])
->getToken();

$this->assertTrue($token->verify($this->signer, static::$ecdsaKeys['public-params']));
}

/**
* @test
*
Expand Down
2 changes: 2 additions & 0 deletions test/functional/Keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public static function createEcdsaKeys()

static::$ecdsaKeys = [
'private' => $keychain->getPrivateKey($dir . '/ecdsa/private.key'),
'private-params' => $keychain->getPrivateKey($dir . '/ecdsa/private2.key'),
'public1' => $keychain->getPublicKey($dir . '/ecdsa/public1.key'),
'public2' => $keychain->getPublicKey($dir . '/ecdsa/public2.key'),
'public-params' => $keychain->getPublicKey($dir . '/ecdsa/public3.key'),
];
}
}
8 changes: 8 additions & 0 deletions test/functional/ecdsa/private2.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIM6G7WZ6SqoPwrHwGXhOJkYD+ErT8dfRvrNifgBQvSb7oAoGCCqGSM49
AwEHoUQDQgAE09Hkp/u0tIGdzlQ99R/sXCOr9DTZAfLex4D4Po0C1L3qUqHrzZ0m
B3bAhe+pwEDQ/jqVqdzxhA9i4PqT7F4Aew==
-----END EC PRIVATE KEY-----
4 changes: 4 additions & 0 deletions test/functional/ecdsa/public3.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE09Hkp/u0tIGdzlQ99R/sXCOr9DTZ
AfLex4D4Po0C1L3qUqHrzZ0mB3bAhe+pwEDQ/jqVqdzxhA9i4PqT7F4Aew==
-----END PUBLIC KEY-----

0 comments on commit 7668cb0

Please sign in to comment.