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

Add CURLE_SSL_CLIENTCERT error #6721

Closed
wants to merge 1 commit into from
Closed

Add CURLE_SSL_CLIENTCERT error #6721

wants to merge 1 commit into from

Conversation

ebejan
Copy link
Contributor

@ebejan ebejan commented Mar 11, 2021

-When server requests client certificate request during handshake, it returns generic error CURLE_SSL_CONNECT_ERROR. This is very specific error, and would like to be handled specifically, so adding different error code CURLE_SSL_CLIENTCERT

@ebejan
Copy link
Contributor Author

ebejan commented Mar 11, 2021

As beginging, adding only to OSX.

@ghost
Copy link

ghost commented Mar 11, 2021

Congratulations 🎉. DeepCode analyzed your code in 0.724 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

I lack a documentation update in docs/libcurl/libcurl-errors.3 but perhaps I'm mostly concerned that this creates a new return code and only it is only used in a single TLS backend, and in one that is mostly deprecated . Did you try to provide it for perhaps at least OpenSSL as well?

docs/libcurl/symbols-in-versions Outdated Show resolved Hide resolved
lib/vtls/sectransp.c Outdated Show resolved Hide resolved
@jay
Copy link
Member

jay commented Mar 12, 2021

What is your use case for this error code, how is it necessary?

@jay jay added the TLS label Mar 12, 2021
@ebejan
Copy link
Contributor Author

ebejan commented Mar 12, 2021

@jay Our curl wrapper detects CURLE_SSL_CLIENTCERT error and negotiates with the other side, gets all the certificates, and let user to select the certain certificates.

@bagder bagder added the feature-window A merge of this requires an open feature window label Mar 17, 2021
@bagder
Copy link
Member

bagder commented Mar 17, 2021

I don't mind adding a new error code for this condition. But...

I think this error code needs to also be supported at least for OpenSSL to be acceptable (and preferably for even more). As a I said before: Secure Transport is more or less deprecated by Apple themselves now and adding a global new curl error code only supported in that niche backend I think isn't meeting the bar we should set for new error codes.

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

I think this error code needs support in more TLS backends before we can merge support it.

@ebeworld
Copy link

I have ported the change to OpenSSL

@ebejan ebejan requested a review from bagder April 13, 2021 02:47
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

I would appreciate if you squashed this set of commits to the lowest number of commits you think think it should use - to ease reviewing.

@@ -3317,6 +3317,11 @@ static CURLcode ossl_connect_step2(struct Curl_easy *data,
error_buffer */
strcpy(error_buffer, "SSL certificate verification failed");
}
else if((lib == ERR_LIB_SSL) &&
(reason == SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED)) {
Copy link
Member

Choose a reason for hiding this comment

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

This sounds TLS 1.3 specific, isn't it?

Choose a reason for hiding this comment

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

Yes, that is true.

Copy link
Member

Choose a reason for hiding this comment

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

So you don't think it's a problem that if you happen to negotiate another TLS version you won't get this error code for the otherwise very similar situation?

Choose a reason for hiding this comment

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

I would like to add the error code to other TLS versions, but don't know how yet. So, wanted to add concepts first TLS 1.3 and above then slowly add for other versions.

@@ -3317,7 +3317,7 @@ static CURLcode ossl_connect_step2(struct Curl_easy *data,
error_buffer */
strcpy(error_buffer, "SSL certificate verification failed");
}
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined(LIBRESSL_VERSION_NUMBER)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this excluding libressl? I think a comment here explaining this could be a good idea.

Choose a reason for hiding this comment

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

SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED is only available on OpenSSL v1.1.1 above and added comments for it.

@ebeworld
Copy link

@bagder I have squashed the changes and added comments as requested.

When server requests client certificate request during handshake, it returns generic error CURLE_SSL_CONNECT_ERROR.

This is very specific error, and would like to be handled specifically, so adding different error code CURLE_SSL_CLIENTCERT
@gvollant
Copy link
Contributor

Do you have an easy method to reproduce this error?

@ebeworld
Copy link

Do you have an easy method to reproduce this error?

@gvollant If the mutual TLS authentication set on both client and server, client does not give its certificates, the error will be return. That is our use case and at that point client asks end user to select certificates for mutual handshake. (in case of client aware of multiple certificates, client does not know which one to provide, hence end users interaction is needed.)

@bagder bagder closed this in 94241a9 May 3, 2021
@bagder
Copy link
Member

bagder commented May 3, 2021

Thanks!

@ebeworld ebeworld deleted the CURLE_SSL_CLIENTCERT branch June 9, 2021 21:41
vszakats added a commit to vszakats/curl that referenced this pull request Aug 7, 2023
OpenSSL 1.1.1 defines this macro, but no ealier version, or any of
the popular forks (yet). Use the macro itself to detect its presence,
replacing the hard-wired fork-specific conditions.

This way the feature will enable automatically when forks implement it,
while also shorter and possibly requiring less future maintenance.

Follow-up to 94241a9 curl#6721

Closes curl#11617
vszakats added a commit that referenced this pull request Aug 8, 2023
OpenSSL 1.1.1 defines this macro, but no ealier version, or any of the
popular forks (yet). Use the macro itself to detect its presence,
replacing the hard-wired fork-specific conditions.

This way the feature will enable automatically when forks implement it,
while also shorter and possibly requiring less future maintenance.

Follow-up to 94241a9 #6721

Reviewed-by: Jay Satiro
Closes #11617
ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
OpenSSL 1.1.1 defines this macro, but no ealier version, or any of the
popular forks (yet). Use the macro itself to detect its presence,
replacing the hard-wired fork-specific conditions.

This way the feature will enable automatically when forks implement it,
while also shorter and possibly requiring less future maintenance.

Follow-up to 94241a9 curl#6721

Reviewed-by: Jay Satiro
Closes curl#11617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-window A merge of this requires an open feature window needs-info TLS
Development

Successfully merging this pull request may close these issues.

None yet

6 participants