Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit b7803b1

Browse files
committed
Fixing broken tests
1 parent 56c2d53 commit b7803b1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Developer/Encryption/JweConfigBuilder.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ private function checkParameterValues() {
9898
* @throws EncryptionException
9999
*/
100100
private function computeEncryptionKeyFingerprint($encryptionCertificate) {
101-
try {
102-
$publicKeyPem = openssl_pkey_get_details(openssl_pkey_get_public($encryptionCertificate->getBytes()))['key'];
103-
$publicKeyDer = EncodingUtils::pemToDer($publicKeyPem, '-----BEGIN PUBLIC KEY-----', '-----END PUBLIC KEY-----');
104-
$hash = new Hash('sha256');
105-
$this->encryptionKeyFingerprint = EncodingUtils::encodeBytes($hash->hash($publicKeyDer), FieldValueEncoding::HEX);
106-
} catch (\Exception $e) {
107-
throw new EncryptionException('Failed to compute encryption key fingerprint!', $e);
101+
if(isset($encryptionCertificate)) {
102+
try {
103+
$publicKeyPem = openssl_pkey_get_details(openssl_pkey_get_public($encryptionCertificate->getBytes()))['key'];
104+
$publicKeyDer = EncodingUtils::pemToDer($publicKeyPem, '-----BEGIN PUBLIC KEY-----', '-----END PUBLIC KEY-----');
105+
$hash = new Hash('sha256');
106+
$this->encryptionKeyFingerprint = EncodingUtils::encodeBytes($hash->hash($publicKeyDer), FieldValueEncoding::HEX);
107+
} catch (\Exception $e) {
108+
throw new EncryptionException('Failed to compute encryption key fingerprint!', $e);
109+
}
108110
}
109111
}
110112

tests/Developer/Encryption/JweConfigBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testBuild_ShouldComputeCertificateKeyFingerprint_WhenFingerprint
5151
->withDecryptionKey($decryptionKey)
5252
->build();
5353

54-
$this->assertEquals("80810fc13a8319fcf0e2ec322c82a4c304b782cc3ce671176343cfe8160c2279", $config->getEncryptionKeyFingerprint());
54+
$this->assertEquals("761b003c1eade3a5490e5000d37887baa5e6ec0e226c07706e599451fc032a79", $config->getEncryptionKeyFingerprint());
5555
}
5656

5757
public function testIntercept_ShouldThrowEncryptionException_WhenInvalidEncryptionCertificate() {

0 commit comments

Comments
 (0)