-
Notifications
You must be signed in to change notification settings - Fork 2.4k
server_certificate_verifier extended to reuse built-in verifier #2064
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
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.
Two notes. Not sure how @yhirose is going to feel about changing public API.
httplib.h
Outdated
enum SSLVerifierResponse { | ||
Verified, // connection certificate is verified and accepted | ||
CheckAgain, // use the built-in certificate checker again | ||
Declined // connection certificate was process but is declined | ||
}; |
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.
Might I suggest different names:
enum SSLVerifierResponse {
NoDecisionMade, // no decision has been made, use built-in certificate verifier
CertificateAccepted, // connection certificate is verified and accepted
CertificateRejected // connection certificate was processed but is rejected
};
Also, order NoDecisionMade
to the top. It makes more sense to be the default enum value and is certainly less dangerous than CertificateAccepted
.
Just two cents from a random contributor...
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.
httplib.h
Outdated
if (server_certificate_verifier_) | ||
verificationStatus = server_certificate_verifier_(ssl2); |
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 code base uses curlies even around single statements. Also, please run clang-format
. This PR would fail #2062.
httplib.h
Outdated
@@ -9623,12 +9634,20 @@ inline bool SSLClient::initialize_ssl(Socket &socket, Error &error) { | |||
} | |||
|
|||
if (server_certificate_verification_) { | |||
SSLVerifierResponse verification_status_ = |
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.
Could you change it to auto verification_status
?
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.
done
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 meant two things, not only auto
, but also verification_status
(without the trailing _
).
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.
sorry, missed that; fixed
@urosg80 the code looks good. Thanks for your contribution! |
Great and thank you for the great library! |
#2061 #2061