Skip to content

Commit 7ab2d1a

Browse files
authored
Merge pull request #211 from web-token/OpenSSLDep
lib-openssl deps fixed
2 parents 07407db + eb8aca9 commit 7ab2d1a

File tree

15 files changed

+57
-4
lines changed

15 files changed

+57
-4
lines changed

src/Bundle/JoseFramework/DataCollector/JoseCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
19+
use Symfony\Component\VarDumper\Cloner\Data;
1920

2021
class JoseCollector extends DataCollector
2122
{
@@ -41,7 +42,10 @@ public function getName()
4142
return 'jose_collector';
4243
}
4344

44-
public function getData(): array
45+
/**
46+
* @return array|Data
47+
*/
48+
public function getData()
4549
{
4650
return $this->data;
4751
}

src/Bundle/JoseFramework/Normalizer/JWENormalizer.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,25 @@ public function supportsDenormalization($data, $type, $format = null)
3030
return JWE::class === $type && $this->componentInstalled();
3131
}
3232

33+
/**
34+
* @param mixed $object Object to normalize
35+
* @param string $format Format the normalization result will be encoded as
36+
*
37+
* @return mixed
38+
*/
3339
public function normalize($object, $format = null, array $context = [])
3440
{
3541
return $object;
3642
}
3743

38-
public function denormalize($data, $class, $format = null, array $context = [])
44+
/**
45+
* @param mixed $data Data to restore
46+
* @param string $type The expected class to instantiate
47+
* @param string $format Format the given data was extracted from
48+
*
49+
* @return array|object
50+
*/
51+
public function denormalize($data, $type, $format = null, array $context = [])
3952
{
4053
return $data;
4154
}

src/Bundle/JoseFramework/Normalizer/JWSNormalizer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ public function normalize($object, $format = null, array $context = [])
3535
return $object;
3636
}
3737

38-
public function denormalize($data, $class, $format = null, array $context = [])
38+
/**
39+
* @param mixed $data Data to restore
40+
* @param string $type The expected class to instantiate
41+
* @param string $format Format the given data was extracted from
42+
* @param array $context Options available to the denormalizer
43+
*
44+
* @return array|object
45+
*/
46+
public function denormalize($data, $type, $format = null, array $context = [])
3947
{
4048
return $data;
4149
}

src/Component/Core/Util/ECKey.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ private static function getNistCurveSize(string $curve): int
123123

124124
private static function createECKeyUsingOpenSSL(string $curve): array
125125
{
126+
if (!\extension_loaded('openssl')) {
127+
throw new RuntimeException('Please install the OpenSSL extension');
128+
}
126129
$key = openssl_pkey_new([
127130
'curve_name' => self::getOpensslCurveName($curve),
128131
'private_key_type' => OPENSSL_KEYTYPE_EC,

src/Component/Encryption/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
}
2121
},
2222
"require": {
23-
"lib-openssl": "*",
2423
"web-token/jwt-core": "^2.1"
2524
},
2625
"require-dev": {

src/Component/KeyManagement/KeyConverter/KeyConverter.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public static function loadKeyFromCertificateFile(string $file): array
3535

3636
public static function loadKeyFromCertificate(string $certificate): array
3737
{
38+
if (!\extension_loaded('openssl')) {
39+
throw new RuntimeException('Please install the OpenSSL extension');
40+
}
41+
3842
try {
3943
$res = openssl_x509_read($certificate);
4044
if (false === $res) {
@@ -59,6 +63,9 @@ public static function loadKeyFromCertificate(string $certificate): array
5963
*/
6064
public static function loadKeyFromX509Resource($res): array
6165
{
66+
if (!\extension_loaded('openssl')) {
67+
throw new RuntimeException('Please install the OpenSSL extension');
68+
}
6269
$key = openssl_get_publickey($res);
6370
if (false === $key) {
6471
throw new InvalidArgumentException('Unable to load the certificate.');
@@ -110,6 +117,10 @@ public static function loadFromX5C(array $x5c): array
110117
if (0 === \count($x5c)) {
111118
throw new InvalidArgumentException('The certificate chain is empty');
112119
}
120+
121+
if (!\extension_loaded('openssl')) {
122+
throw new RuntimeException('Please install the OpenSSL extension');
123+
}
113124
$certificate = null;
114125
$last_issuer = null;
115126
$last_subject = null;
@@ -157,6 +168,9 @@ private static function loadKeyFromPEM(string $pem, ?string $password = null): a
157168
$pem = self::decodePem($pem, $matches, $password);
158169
}
159170

171+
if (!\extension_loaded('openssl')) {
172+
throw new RuntimeException('Please install the OpenSSL extension');
173+
}
160174
self::sanitizePEM($pem);
161175
$res = openssl_pkey_get_private($pem);
162176
if (false === $res) {

src/Component/KeyManagement/KeyConverter/RSAKey.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use InvalidArgumentException;
1818
use Jose\Component\Core\JWK;
1919
use Jose\Component\Core\Util\BigInteger;
20+
use RuntimeException;
2021

2122
/**
2223
* @internal
@@ -67,6 +68,9 @@ public static function createFromKeyDetails(array $details): self
6768
*/
6869
public static function createFromPEM(string $pem): self
6970
{
71+
if (!\extension_loaded('openssl')) {
72+
throw new RuntimeException('Please install the OpenSSL extension');
73+
}
7074
$res = openssl_pkey_get_private($pem);
7175
if (false === $res) {
7276
$res = openssl_pkey_get_public($pem);

src/EncryptionAlgorithm/ContentEncryption/AESCBC/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
},
2222
"require": {
23+
"lib-openssl": "*",
2324
"web-token/jwt-encryption": "^2.1"
2425
},
2526
"require-dev": {

src/EncryptionAlgorithm/ContentEncryption/AESGCM/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
},
2222
"require": {
23+
"lib-openssl": "*",
2324
"web-token/jwt-encryption": "^2.1"
2425
},
2526
"require-dev": {

src/EncryptionAlgorithm/KeyEncryption/AESGCMKW/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
},
2222
"require": {
23+
"lib-openssl": "*",
2324
"spomky-labs/aes-key-wrap": "^5.0",
2425
"web-token/jwt-encryption": "^2.1"
2526
},

0 commit comments

Comments
 (0)