Skip to content
Snippets Groups Projects
Unverified Commit 10214fbe authored by Morris Jobke's avatar Morris Jobke Committed by GitHub
Browse files

Merge pull request #25214 from nextcloud/dependabot/composer/phpseclib/phpseclib-2.0.30

Bump phpseclib/phpseclib from 2.0.25 to 2.0.30
parents d4d33e30 fcbbcaca
No related branches found
No related tags found
No related merge requests found
Subproject commit 099e537a03d162302c2366f7d53088d5bf623c4c Subproject commit 3faef8dfa15d0b946759bdb888d5b245de6fb524
...@@ -141,6 +141,7 @@ class SFTP extends \OC\Files\Storage\Common { ...@@ -141,6 +141,7 @@ class SFTP extends \OC\Files\Storage\Common {
$login = false; $login = false;
foreach ($this->auth as $auth) { foreach ($this->auth as $auth) {
/** @psalm-suppress TooManyArguments */
$login = $this->client->login($this->user, $auth); $login = $this->client->login($this->user, $auth);
if ($login === true) { if ($login === true) {
break; break;
......
...@@ -215,6 +215,18 @@ class Installer { ...@@ -215,6 +215,18 @@ class Installer {
return false; return false;
} }
/**
* 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];
}
/** /**
* Downloads an app and puts it into the app directory * Downloads an app and puts it into the app directory
* *
...@@ -231,12 +243,18 @@ class Installer { ...@@ -231,12 +243,18 @@ class Installer {
if ($app['id'] === $appId) { if ($app['id'] === $appId) {
// Load the certificate // Load the certificate
$certificate = new X509(); $certificate = new X509();
$certificate->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt')); $rootCrt = file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt');
$rootCrts = $this->splitCerts($rootCrt);
foreach ($rootCrts as $rootCrt) {
$certificate->loadCA($rootCrt);
}
$loadedCertificate = $certificate->loadX509($app['certificate']); $loadedCertificate = $certificate->loadX509($app['certificate']);
// Verify if the certificate has been revoked // Verify if the certificate has been revoked
$crl = new X509(); $crl = new X509();
$crl->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt')); foreach ($rootCrts as $rootCrt) {
$crl->loadCA($rootCrt);
}
$crl->loadCRL(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crl')); $crl->loadCRL(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crl'));
if ($crl->validateSignature() !== true) { if ($crl->validateSignature() !== true) {
throw new \Exception('Could not validate CRL signature'); throw new \Exception('Could not validate CRL signature');
......
...@@ -299,6 +299,18 @@ class Checker { ...@@ -299,6 +299,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. * Verifies the signature for the specified path.
* *
...@@ -333,7 +345,11 @@ class Checker { ...@@ -333,7 +345,11 @@ class Checker {
// Check if certificate is signed by Nextcloud Root Authority // Check if certificate is signed by Nextcloud Root Authority
$x509 = new \phpseclib\File\X509(); $x509 = new \phpseclib\File\X509();
$rootCertificatePublicKey = $this->fileAccessHelper->file_get_contents($this->environmentHelper->getServerRoot().'/resources/codesigning/root.crt'); $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); $x509->loadX509($certificate);
if (!$x509->validateSignature()) { if (!$x509->validateSignature()) {
throw new InvalidSignatureException('Certificate is not valid.'); throw new InvalidSignatureException('Certificate is not valid.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment