diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-09-24 10:33:07 +0200 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2024-09-24 12:36:09 +0200 |
commit | 19ad13571cfb0c1708b18064541646ddaa4ef6ac (patch) | |
tree | 1fb1f5149e612e68b88021037f50b9835b720996 /lib | |
parent | 12ed773b58f023a642a4f03acfa8a5f9c3d58ce5 (diff) | |
download | nextcloud-server-19ad13571cfb0c1708b18064541646ddaa4ef6ac.tar.gz nextcloud-server-19ad13571cfb0c1708b18064541646ddaa4ef6ac.zip |
fix: gracefully parse non-standard trusted certificatesfix/gracefully-parse-trusted-certificates
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Security/Certificate.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/private/Security/Certificate.php b/lib/private/Security/Certificate.php index b9d84caeca3..1551694c21f 100644 --- a/lib/private/Security/Certificate.php +++ b/lib/private/Security/Certificate.php @@ -42,6 +42,16 @@ class Certificate implements ICertificate { $info = openssl_x509_parse($data); if (!is_array($info)) { + // There is a non-standardized certificate format only used by OpenSSL. Replace all + // separators and try again. + $data = str_replace( + ['-----BEGIN TRUSTED CERTIFICATE-----', '-----END TRUSTED CERTIFICATE-----'], + ['-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----'], + $data, + ); + $info = openssl_x509_parse($data); + } + if (!is_array($info)) { throw new \Exception('Certificate could not get parsed.'); } |