Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(s3): support SSE-C headers for the MultipartCopy call #41366

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

ir0nhide
Copy link
Contributor

@ir0nhide ir0nhide commented Nov 9, 2023

Since a few weeks, I see a lot of HTTP 400 Bad Request errors on HeadObject calls in my Nextcloud logs.
Furthermore I realized, that it is no longer possible to copy a file using the Web-UI.
After further investigations I found out, that this problem is related to the switch to MultipartCopy for copyObject operations on S3 Object Storages.

Looking into the code of the AWS PHP SDK, MultipartCopy executes a headObject request to retrieve the metadata of the source object:
https://github.com/aws/aws-sdk-php/blob/master/src/S3/MultipartCopy.php#L193
Unfortunately, this request is executed without adding any additional Headers like SSE-C, so that this call fails on setups using SSE-C.

To fix this issue, the source object's metadata can be fetched by a separate headObject request and directly provided to the MultipartCopy object as an input argument, skipping the included headObject request (https://github.com/aws/aws-sdk-php/blob/master/src/S3/MultipartCopy.php#L196).

This Pull Requests fixes the broken copyObject function on Nextcloud setups using SSE-C for Primary S3 Object Storage.

@solracsf solracsf added the 3. to review Waiting for reviews label Nov 9, 2023
@solracsf solracsf added this to the Nextcloud 28 milestone Nov 9, 2023
Copy link
Member

@juliushaertl juliushaertl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small codestyle comment, but otherwise this looks good 👍

@blizzz blizzz mentioned this pull request Nov 9, 2023
@ir0nhide
Copy link
Contributor Author

ir0nhide commented Nov 9, 2023

@juliushaertl thank you for the review, codestyle should be better now.

@solracsf
Copy link
Member

Small comment as we normaly use camelCase for variables. Good otherwise.

@ir0nhide
Copy link
Contributor Author

@solracsf thanks for the review, should be fixed now.

@blizzz blizzz mentioned this pull request Nov 10, 2023
Signed-off-by: Tobias Zimmerer <3228193+ir0nhide@users.noreply.github.com>
@blizzz blizzz mentioned this pull request Nov 14, 2023
@juliushaertl juliushaertl merged commit 830d85b into nextcloud:master Nov 15, 2023
47 of 50 checks passed
@juliushaertl
Copy link
Member

/backport to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants