You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2020/04/05 08:24:00 UTC

[jira] [Updated] (HTTPCLIENT-2073) HttpClient doesn't authenticate with NTLM on Windows

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-2073?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov updated HTTPCLIENT-2073:
---------------------------------------
    Description: 
Running this:

{code:java}
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();
}
{code:java}
I get an error. See the attached log file. The same code works with Http Client v 4.5.12

  was:
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


> HttpClient doesn't authenticate with NTLM on Windows
> ----------------------------------------------------
>
>                 Key: HTTPCLIENT-2073
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2073
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (Windows)
>    Affects Versions: 5.0
>         Environment: OS: Windows 10
> JRE: AdoptOpenJdk v11
> Proxy type: NTLM (Wingate)
>            Reporter: Covaci Eugen
>            Priority: Major
>         Attachments: bug.txt
>
>
> Running this:
> {code:java}
> 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();
> }
> {code:java}
> I get an error. See the attached log file. The same code works with Http Client v 4.5.12



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org