-
Notifications
You must be signed in to change notification settings - Fork 5
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
S3 C++: Replace the remaing c code[WIP] Fixes #11 #21
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you. There are just a couple of style issues to fix.
There's still some lingering C code being called in S3ListResult::onFinished()
that's preventing s3.h
from being removed. This can be addressed separately, but I guess I wanted to check that this is intentional. Is that correct?
7a57eed
to
472ad31
Compare
I don't have much knowledge of the s3 c code but this could be a replacement for the c code in C++/Qt removing the need for direct openssl use: |
Sorry for taking so long to reply; I hadn't noticed I'd left this question hanging. That's a nice find, but as it happens the openssl linkage will be needed for other things, so I'd prefer to stick with openssl throughout. However the usage in |
It should be possible to simplify the MD5 code similarly: https://www.openssl.org/docs/man1.1.1/man3/MD5.html |
c288979
to
ff3e4e3
Compare
Is the md5 function used somewhere? |
The only instance I could see was in |
ead11c8
to
d8a173f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great and looking nice and clean. I tested it, and with the "date" part added in it worked great too. I made a few style requests, but the only change that's essential to getting it to work is for the "date" line to be fixed.
src/s3access.cpp
Outdated
break; | ||
} | ||
|
||
QString signData = methodStr + "\n\n\n" + + "\n/" + m_bucket + "/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a date missing from here. It should be:
String signData = methodStr + "\n\n\n" + date + "\n/" + m_bucket + "/";
src/s3access.cpp
Outdated
methodStr = "PUT"; | ||
qDebug() << "PUT request"; | ||
break; | ||
case GET: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the case GET:
here to match the code further down (or add the same code at line, but best to stay consistent with it).
src/s3access.cpp
Outdated
{ | ||
QNetworkRequest request; | ||
char *digest; | ||
unsigned char digest[EVP_MAX_MD_SIZE +1 ]; // +1 for the \0 byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The +1 is no longer needed here (since you're not adding the null byte after all).
QString signData = methodStr + "\n\n\n" + + "\n/" + m_bucket + "/"; | ||
|
||
if (signDataKey != nullptr) | ||
signData+=signDataKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency (and because it's a common source of error) I'd be grateful if you could include the curly brackets here.
@@ -168,7 +177,6 @@ QNetworkReply *S3Access::performOp(Method method, QString const &url, QString co | |||
break; | |||
} | |||
|
|||
free(digest); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra line here after you've removed the free(digest)
. If you could remove it, that would be appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that line, I just removed that line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wasn't very clear. I mean if you have this:
1.
2. statement
3.
and then remove statement
, you end up with two blank lines:
1.
3.
but for purely aesthetic reasons there should only be a single blank line after the switch statement.
Moved the creation of the signData string to performOp making s3_make_date() unneeded. Added signDataKey to allow for optional signData key for methods like getFile(). Should also make adding methods that user other Methods easier. Also cleanes up the converting of date to QString and just converts it to QBytearray when needed.
Instead of using s3_hmac_sign() which does everything on its own resuse HMAC() from OpenSSL. This adds some casting that was done previously inside s3_hmac_sign() to performOp(). In addition we no longer use the deprecated HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md) (<1.1). Removes the usage of: + s3_hmac_sign() Contributes to llewelld#11
The S3 struct is no longer used since all c-style s3 methods are no longer used. Remove all code that related to it. Removes the usage of: + s3_free() + s3_init() Contributes to llewelld#11.
You still have [WIP] in the title, but this is good enough -- and substantial enough -- to merge in its current form. Did you have other changes in mind? If you did, it might make sense to put them in a follow-up PR, if you prefer? |
I'd replace the s3 buckets struct if you don't mind and merge this
afterwards.
Then hole code of the s3 folder is no longer needed.
|
Currently so far: