Skip to content

Commit 3f45bc5

Browse files
Merge pull request #50514 from nextcloud/feat/s3/sse-c
feat(S3): add SSE-C support in S3 External Storage
2 parents 0500886 + f1c025d commit 3f45bc5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

apps/files_external/lib/Lib/Backend/AmazonS3.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function __construct(IL10N $l, AccessKey $legacyAuth) {
4141
(new DefinitionParameter('useMultipartCopy', $l->t('Enable multipart copy')))
4242
->setType(DefinitionParameter::VALUE_BOOLEAN)
4343
->setDefaultValue(true),
44+
(new DefinitionParameter('sse_c_key', $l->t('SSE-C encryption key')))
45+
->setType(DefinitionParameter::VALUE_PASSWORD)
46+
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
4447
])
4548
->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
4649
->addAuthScheme(AuthMechanism::SCHEME_NULL)

apps/files_external/lib/Lib/Storage/AmazonS3.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private function headObject(string $key): array|false {
113113
$this->objectCache[$key] = $this->getConnection()->headObject([
114114
'Bucket' => $this->bucket,
115115
'Key' => $key
116-
])->toArray();
116+
] + $this->getSSECParameters())->toArray();
117117
} catch (S3Exception $e) {
118118
if ($e->getStatusCode() >= 500) {
119119
throw $e;
@@ -207,7 +207,7 @@ public function mkdir(string $path): bool {
207207
'Key' => $path . '/',
208208
'Body' => '',
209209
'ContentType' => FileInfo::MIMETYPE_FOLDER
210-
]);
210+
] + $this->getSSECParameters());
211211
$this->testTimeout();
212212
} catch (S3Exception $e) {
213213
$this->logger->error($e->getMessage(), [
@@ -507,7 +507,7 @@ public function touch(string $path, ?int $mtime = null): bool {
507507
'Body' => '',
508508
'ContentType' => $mimeType,
509509
'MetadataDirective' => 'REPLACE',
510-
]);
510+
] + $this->getSSECParameters());
511511
$this->testTimeout();
512512
} catch (S3Exception $e) {
513513
$this->logger->error($e->getMessage(), [

lib/private/Files/ObjectStore/S3ConnectionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ protected function getCertificateBundlePath(): ?string {
213213
}
214214

215215
protected function getSSECKey(): ?string {
216-
if (isset($this->params['sse_c_key'])) {
216+
if (isset($this->params['sse_c_key']) && !empty($this->params['sse_c_key'])) {
217217
return $this->params['sse_c_key'];
218218
}
219219

0 commit comments

Comments
 (0)