Set outputLength correctly on open ended range requests to encryptedBlobStore#706
Conversation
|
Can you add a unit test that demonstrates this problem? I wonder how does encryption work for range requests? I would imagine that S3Proxy needs to decrypt either the entire object or at least whatever the encryption block size is. CC @FlorinPeter who wrote the original code. |
|
Partial decryption is already extensively tested in As confirmed by these tests, the content s3proxy returns for encrypted blobs for any ranged request is correct. Just the ContentLength response header is incorrect in the described case, due to the bug in the |
gaul
left a comment
There was a problem hiding this comment.
Thanks for the explanation! Please fit the nits so I can merge this.
|
Thank you for your contribution and explanation @ptemarvelde! I didn't write this middleware and don't have a good understanding how it works. |
This resolves #698.
Open ended ranged requests to encrypted files resulted in incorrect Content-Length headers in the response because of a bug in the Decryption class.
In EncryptedBloBStore the length is set to
-1by default. On open-ended ranged GET requests this value is passed to theDecryptionconstructor, which in turn only setsoutputLengthif anoffsetis given without alength, but-1is used to represent no length given. After this change theoutputLengthis set correctly in this constructor.https://github.com/gaul/s3proxy/blob/master/src/main/java/org/gaul/s3proxy/EncryptedBlobStore.java#L375
@gaul The tests pass (locally) but I have not spend enough time with this codebase to reason about whether this change will break anything else (which is currently untested). Is this a reasonable solution for #698?