This repository was archived by the owner on Feb 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
tests/Developer/Encryption Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments