File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ private static function parseKey(array $jwk)
82
82
83
83
switch ($ jwk ['kty ' ]) {
84
84
case 'RSA ' :
85
- if (\array_key_exists ( 'd ' , $ jwk )) {
85
+ if (! empty ( $ jwk [ 'd ' ] )) {
86
86
throw new UnexpectedValueException ('RSA private keys are not supported ' );
87
87
}
88
88
if (!isset ($ jwk ['n ' ]) || !isset ($ jwk ['e ' ])) {
Original file line number Diff line number Diff line change @@ -32,6 +32,36 @@ public function testInvalidAlgorithm()
32
32
$ keys = JWK ::parseKeySet (array ('keys ' => array ($ badJwk )));
33
33
}
34
34
35
+ public function testParsePrivateKey ()
36
+ {
37
+ $ this ->setExpectedException (
38
+ 'UnexpectedValueException ' ,
39
+ 'RSA private keys are not supported '
40
+ );
41
+
42
+ $ jwkSet = json_decode (
43
+ file_get_contents (__DIR__ . '/rsa-jwkset.json ' ),
44
+ true
45
+ );
46
+ $ jwkSet ['keys ' ][0 ]['d ' ] = 'privatekeyvalue ' ;
47
+
48
+ JWK ::parseKeySet ($ jwkSet );
49
+ }
50
+
51
+ public function testParseKeyWithEmptyDValue ()
52
+ {
53
+ $ jwkSet = json_decode (
54
+ file_get_contents (__DIR__ . '/rsa-jwkset.json ' ),
55
+ true
56
+ );
57
+
58
+ // empty or null values are ok
59
+ $ jwkSet ['keys ' ][0 ]['d ' ] = null ;
60
+
61
+ $ keys = JWK ::parseKeySet ($ jwkSet );
62
+ $ this ->assertTrue (is_array ($ keys ));
63
+ }
64
+
35
65
public function testParseJwkKeySet ()
36
66
{
37
67
$ jwkSet = json_decode (
You can’t perform that action at this time.
0 commit comments