Skip to content

CURLINFO_PROXYAUTH_AVAIL is 0 after resetting user name and password #21274

@sergio-nsk

Description

@sergio-nsk

I did this

Simplified code

    CURL *curl = curl_easy_init();
    ASSERT_NE(curl, nullptr);

    curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
    curl_easy_setopt(curl, CURLOPT_PROXY, "http://digest-proxy:80");
    curl_easy_perform(curl);

    long code = 0;
    long auth = 0;
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
    curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_AVAIL, &auth);
    EXPECT_EQ(code, 407);
    EXPECT_EQ(auth, CURLAUTH_DIGEST);

    curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "usr");
    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "pswrd");
    curl_easy_perform(curl);

    char *location;
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
    curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_USED, &auth);
    curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &location);
    EXPECT_EQ(code, 301);
    EXPECT_EQ(auth, CURLAUTH_DIGEST);  // Fail: 0 != 2
    EXPECT_STREQ(location, "https://example.com");

    // Redirection

    curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, nullptr);
    curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, nullptr);
    curl_easy_setopt(curl, CURLOPT_URL, location);
    curl_easy_perform(curl);

    curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
    curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_AVAIL, &auth);
    EXPECT_EQ(code, 407);
    EXPECT_EQ(auth, CURLAUTH_DIGEST);  // Fail: 0 != 2

    curl_easy_cleanup(curl);
  • Getting http://example.com/ through a proxy with the digest authentication.
  • Receiving 407. CURLINFO_PROXYAUTH_AVAIL is 2 - OK
  • Setting a proxy user name and password, getting http://example.com/ again.
  • Receiving 301. CURLINFO_PROXYAUTH_USED is 0, expected 2 - FAIL.
  • Setting a new url and resetting a proxy user name and password.
  • Receiving 407. CURLINFO_PROXYAUTH_AVAIL is 0 expected 2 - FAIL.

The issue seems to be in the function auth_digest(), it does not set data->info.proxyauthavail if data->state.authproxy.avail is set previously.

I expected the following

No response

curl/libcurl version

curl 8.17.0

operating system

Windows 10

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions