diff options
author | Robin Appelman <robin@icewind.nl> | 2022-06-21 16:50:06 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2022-07-18 07:57:46 +0000 |
commit | 9d4b0e22659238e375235106a2f3dca05ef6d805 (patch) | |
tree | 9de9d3596c5c86e9de418caae5a26ef050275766 | |
parent | 4b385a44cb2a7e3543fdaa691b201d10f51da9b3 (diff) | |
download | nextcloud-server-9d4b0e22659238e375235106a2f3dca05ef6d805.tar.gz nextcloud-server-9d4b0e22659238e375235106a2f3dca05ef6d805.zip |
also use nextcloud certificate bundle when downloading from s3
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/ObjectStore/S3ConnectionTrait.php | 22 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/S3ObjectTrait.php | 5 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 03166ab1d7e..d38f553fdf6 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -122,15 +122,6 @@ trait S3ConnectionTrait { ) ); - // since we store the certificate bundles on the primary storage, we can't get the bundle while setting up the primary storage - if (!isset($this->params['primary_storage'])) { - /** @var ICertificateManager $certManager */ - $certManager = \OC::$server->get(ICertificateManager::class); - $certPath = $certManager->getAbsoluteBundlePath(); - } else { - $certPath = \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; - } - $options = [ 'version' => isset($this->params['version']) ? $this->params['version'] : 'latest', 'credentials' => $provider, @@ -140,7 +131,7 @@ trait S3ConnectionTrait { 'signature_provider' => \Aws\or_chain([self::class, 'legacySignatureProvider'], ClientResolver::_default_signature_provider()), 'csm' => false, 'use_arn_region' => false, - 'http' => ['verify' => $certPath], + 'http' => ['verify' => $this->getCertificateBundlePath()], ]; if ($this->getProxy()) { $options['http']['proxy'] = $this->getProxy(); @@ -220,4 +211,15 @@ trait S3ConnectionTrait { return new RejectedPromise(new CredentialsException($msg)); }; } + + protected function getCertificateBundlePath(): string { + // since we store the certificate bundles on the primary storage, we can't get the bundle while setting up the primary storage + if (!isset($this->params['primary_storage'])) { + /** @var ICertificateManager $certManager */ + $certManager = \OC::$server->get(ICertificateManager::class); + return $certManager->getAbsoluteBundlePath(); + } else { + return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; + } + } } diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index cdaa202dbe8..9a2f5b2c6df 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -43,6 +43,8 @@ trait S3ObjectTrait { */ abstract protected function getConnection(); + abstract protected function getCertificateBundlePath(): string; + /** * @param string $urn the unified resource name used to identify the object * @return resource stream with the read data @@ -68,6 +70,9 @@ trait S3ObjectTrait { 'protocol_version' => $request->getProtocolVersion(), 'header' => $headers, ], + 'ssl' => [ + 'cafile' => $this->getCertificateBundlePath() + ] ]; if ($this->getProxy()) { |