Skip to content

Commit cd27f60

Browse files
jszakmeistergitster
authored andcommitted
http: store credential when PKI auth is used
We already looked for the PKI credentials in the credential store, but failed to approve it on success. Meaning, the PKI certificate password was never stored and git would request it on every connection to the remote. Let's complete the chain by storing the certificate password on success. Likewise, we also need to reject the credential when there is a failure. Curl appears to report client-related certificate issues are reported with the CURLE_SSL_CERTPROBLEM error. This includes not only a bad password, but potentially other client certificate related problems. Since we cannot get more information from curl, we'll go ahead and reject the credential upon receiving that error, just to be safe and avoid caching or saving a bad password. Signed-off-by: John Szakmeister <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 13d7ab6 commit cd27f60

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,17 @@ static int handle_curl_result(struct slot_results *results)
16371637
credential_approve(&http_auth);
16381638
if (proxy_auth.password)
16391639
credential_approve(&proxy_auth);
1640+
credential_approve(&cert_auth);
16401641
return HTTP_OK;
1642+
} else if (results->curl_result == CURLE_SSL_CERTPROBLEM) {
1643+
/*
1644+
* We can't tell from here whether it's a bad path, bad
1645+
* certificate, bad password, or something else wrong
1646+
* with the certificate. So we reject the credential to
1647+
* avoid caching or saving a bad password.
1648+
*/
1649+
credential_reject(&cert_auth);
1650+
return HTTP_NOAUTH;
16411651
} else if (missing_target(results))
16421652
return HTTP_MISSING_TARGET;
16431653
else if (results->http_code == 401) {

0 commit comments

Comments
 (0)