Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2073

HttpClient doesn't authenticate with NTLM on Windows

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0.1
    • Component/s: HttpClient (Windows)
    • Labels:
    • Environment:
      OS: Windows 10
      JRE: AdoptOpenJdk v11
      Proxy type: NTLM (Wingate)

      Description

      Running this:

      try (CloseableHttpClient httpClient = WinHttpClients.createDefault()) {
      	HttpHost target = HttpHost.create("http://example.com");
      	HttpHost proxy = new HttpHost("http", "localhost", 80);
      	RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
      	HttpGet request = new HttpGet("/");
      	request.setConfig(config);
      	try (CloseableHttpResponse response = httpClient.execute(target, request)) {
      		StatusLine statusLine = new StatusLine(response);
      		if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
      			System.out.println("Test OK");
      		} else if (statusLine.getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
      			throw new CredentialException(statusLine.getReasonPhrase());
      		}
      	}
      } catch (Exception e) {
      	e.printStackTrace();
      }
      

      I get an error. See the attached log file. The same code works with Http Client v 4.5.12

        Attachments

        1. bug.txt
          10 kB
          Eugen Covaci
        2. error1.txt
          12 kB
          Eugen Covaci
        3. log_ok_v4.5.12.txt
          10 kB
          Eugen Covaci
        4. log_ok_v5.0.txt
          30 kB
          Eugen Covaci

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eugen.covaci.q Eugen Covaci
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: