mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
Merge pull request #31574 from nextcloud/s3-crt-bundle
use the nextcloud certificate bundle for s3
This commit is contained in:
commit
bf48c0b1b4
3 changed files with 24 additions and 8 deletions
|
|
@ -30,6 +30,7 @@ class S3 implements IObjectStore {
|
|||
use S3ObjectTrait;
|
||||
|
||||
public function __construct($parameters) {
|
||||
$parameters['primary_storage'] = true;
|
||||
$this->parseParams($parameters);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Aws\S3\Exception\S3Exception;
|
|||
use Aws\S3\S3Client;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Promise\RejectedPromise;
|
||||
use OCP\ICertificateManager;
|
||||
use OCP\ILogger;
|
||||
|
||||
trait S3ConnectionTrait {
|
||||
|
|
@ -120,6 +121,15 @@ 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,
|
||||
|
|
@ -129,9 +139,10 @@ trait S3ConnectionTrait {
|
|||
'signature_provider' => \Aws\or_chain([self::class, 'legacySignatureProvider'], ClientResolver::_default_signature_provider()),
|
||||
'csm' => false,
|
||||
'use_arn_region' => false,
|
||||
'http' => ['verify' => $certPath],
|
||||
];
|
||||
if ($this->getProxy()) {
|
||||
$options['http'] = [ 'proxy' => $this->getProxy() ];
|
||||
$options['http']['proxy'] = $this->getProxy();
|
||||
}
|
||||
if (isset($this->params['legacy_auth']) && $this->params['legacy_auth']) {
|
||||
$options['signature_version'] = 'v2';
|
||||
|
|
|
|||
|
|
@ -240,15 +240,19 @@ class CertificateManager implements ICertificateManager {
|
|||
* @return string
|
||||
*/
|
||||
public function getAbsoluteBundlePath(): string {
|
||||
if (!$this->hasCertificates()) {
|
||||
try {
|
||||
if (!$this->hasCertificates()) {
|
||||
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
|
||||
}
|
||||
|
||||
if ($this->needsRebundling()) {
|
||||
$this->createCertificateBundle();
|
||||
}
|
||||
|
||||
return $this->view->getLocalFile($this->getCertificateBundle());
|
||||
} catch (\Exception $e) {
|
||||
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
|
||||
}
|
||||
|
||||
if ($this->needsRebundling()) {
|
||||
$this->createCertificateBundle();
|
||||
}
|
||||
|
||||
return $this->view->getLocalFile($this->getCertificateBundle());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue