diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-01-20 10:56:06 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2021-01-20 10:57:41 +0100 |
commit | fcbbcacab4dc0178c7fdf1a61cfb81f922c60209 (patch) | |
tree | 1a752e8dfe8bdd96618f4561f5f7949b067757ef /lib | |
parent | d751fedffb110aca956e9f786cd9ecdafdfa6ecd (diff) | |
download | nextcloud-server-fcbbcacab4dc0178c7fdf1a61cfb81f922c60209.tar.gz nextcloud-server-fcbbcacab4dc0178c7fdf1a61cfb81f922c60209.zip |
Also load CA properly in integrity check
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/IntegrityCheck/Checker.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index fc28d0e7393..122fac8927f 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -300,6 +300,18 @@ class Checker { } /** + * Split the certificate file in individual certs + * + * @param string $cert + * @return string[] + */ + private function splitCerts(string $cert): array { + preg_match_all('([\-]{3,}[\S\ ]+?[\-]{3,}[\S\s]+?[\-]{3,}[\S\ ]+?[\-]{3,})', $cert, $matches); + + return $matches[0]; + } + + /** * Verifies the signature for the specified path. * * @param string $signaturePath @@ -333,7 +345,11 @@ class Checker { // Check if certificate is signed by Nextcloud Root Authority $x509 = new \phpseclib\File\X509(); $rootCertificatePublicKey = $this->fileAccessHelper->file_get_contents($this->environmentHelper->getServerRoot().'/resources/codesigning/root.crt'); - $x509->loadCA($rootCertificatePublicKey); + + $rootCerts = $this->splitCerts($rootCertificatePublicKey); + foreach ($rootCerts as $rootCert) { + $x509->loadCA($rootCert); + } $x509->loadX509($certificate); if (!$x509->validateSignature()) { throw new InvalidSignatureException('Certificate is not valid.'); |