Skip to content

Commit d09096e

Browse files
NFC-102 Cert fix
Signed-off-by: Sander Kondratjev <[email protected]>
1 parent 815f0a7 commit d09096e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/certificate/CertificateLoader.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
namespace web_eid\web_eid_authtoken_validation_php\certificate;
2828

29+
use SodiumException;
2930
use web_eid\web_eid_authtoken_validation_php\exceptions\CertificateDecodingException;
3031
use phpseclib3\File\X509;
3132
use BadFunctionCallException;
@@ -41,7 +42,7 @@ public function __construct()
4142
/**
4243
* Loads certificate files from paths into array of OpenSSLCertificate
4344
* @param string ...$resourceNames array of certificate paths
44-
*
45+
*
4546
* @return array
4647
* @throws CertificateDecodingException
4748
*/
@@ -73,8 +74,14 @@ public static function decodeCertificateFromBase64(string $base64): X509
7374
"-----END CERTIFICATE-----\n";
7475
}
7576

76-
if (!$cert->loadX509($base64)) {
77-
throw new CertificateDecodingException("unverifiedSigningCertificate is not base64 encoded");
77+
try {
78+
if (!$cert->loadX509($base64)) {
79+
throw new CertificateDecodingException(
80+
"unverifiedSigningCertificate is not base64 encoded");
81+
}
82+
} catch (SodiumException) {
83+
throw new CertificateDecodingException(
84+
"unverifiedSigningCertificate is not base64 encoded");
7885
}
7986

8087
return $cert;

0 commit comments

Comments
 (0)