# [PATCH v3 2/2] http: drop the check for an empty proxy password before approving

4 messages from 2021-03-12 to 2021-03-12. Participants: John Szakmeister, brian m. carlson.
Thread: https://gitlist.dev/t/55298

## John Szakmeister, 2021-03-12 02:40

Subject: [PATCH v3 2/2] http: drop the check for an empty proxy password before approving
Message-ID: <20210312024027.33418-3-john@szakmeister.net>
URL: https://gitlist.dev/e/20210312024027.33418-3-john%40szakmeister.net
In-Reply-To: <20210312024027.33418-1-john@szakmeister.net>

```
credential_approve() already checks for a non-empty password before
saving, so there's no need to do the extra check here.

Signed-off-by: John Szakmeister <john@szakmeister.net>
---
 http.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/http.c b/http.c
index 60d01c6e83..3aeabf0947 100644
--- a/http.c
+++ b/http.c
@@ -1635,8 +1635,7 @@ static int handle_curl_result(struct slot_results *results)
 
 	if (results->curl_result == CURLE_OK) {
 		credential_approve(&http_auth);
-		if (proxy_auth.password)
-			credential_approve(&proxy_auth);
+		credential_approve(&proxy_auth);
 		credential_approve(&cert_auth);
 		return HTTP_OK;
 	} else if (results->curl_result == CURLE_SSL_CERTPROBLEM) {
-- 
2.30.1


```

## John Szakmeister, 2021-03-12 02:40

Subject: [PATCH v3 0/2] http: store credential when PKI auth is used
Message-ID: <20210312024027.33418-1-john@szakmeister.net>
URL: https://gitlist.dev/e/20210312024027.33418-1-john%40szakmeister.net

```
Essentially the same, but rejecting the correcting credential this time.

John Szakmeister (2):
  http: store credential when PKI auth is used
  http: drop the check for an empty proxy password before approving

 http.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

-- 
2.30.1


```

## John Szakmeister, 2021-03-12 02:40

Subject: [PATCH v3 1/2] http: store credential when PKI auth is used
Message-ID: <20210312024027.33418-2-john@szakmeister.net>
URL: https://gitlist.dev/e/20210312024027.33418-2-john%40szakmeister.net
In-Reply-To: <20210312024027.33418-1-john@szakmeister.net>

```
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 <john@szakmeister.net>
---
 http.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/http.c b/http.c
index f8ea28bb2e..60d01c6e83 100644
--- a/http.c
+++ b/http.c
@@ -1637,7 +1637,17 @@ static int handle_curl_result(struct slot_results *results)
 		credential_approve(&http_auth);
 		if (proxy_auth.password)
 			credential_approve(&proxy_auth);
+		credential_approve(&cert_auth);
 		return HTTP_OK;
+	} else if (results->curl_result == CURLE_SSL_CERTPROBLEM) {
+		/*
+		 * We can't tell from here whether it's a bad path, bad
+		 * certificate, bad password, or something else wrong
+		 * with the certificate.  So we reject the credential to
+		 * avoid caching or saving a bad password.
+		 */
+		credential_reject(&cert_auth);
+		return HTTP_NOAUTH;
 	} else if (missing_target(results))
 		return HTTP_MISSING_TARGET;
 	else if (results->http_code == 401) {
-- 
2.30.1


```

## brian m. carlson, 2021-03-12 21:03

Subject: Re: [PATCH v3 0/2] http: store credential when PKI auth is used
Message-ID: <YEvXPIYbXeTvWhRz@camp.crustytoothpaste.net>
URL: https://gitlist.dev/e/YEvXPIYbXeTvWhRz%40camp.crustytoothpaste.net
In-Reply-To: <20210312024027.33418-1-john@szakmeister.net>

```
On 2021-03-12 at 02:40:25, John Szakmeister wrote:
> Essentially the same, but rejecting the correcting credential this time.
> 
> John Szakmeister (2):
>   http: store credential when PKI auth is used
>   http: drop the check for an empty proxy password before approving
> 
>  http.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)

I looked and this seems sensible.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

```
