Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not work proxy auth #13

Closed
shige0102 opened this issue Jun 18, 2018 · 10 comments
Closed

Can not work proxy auth #13

shige0102 opened this issue Jun 18, 2018 · 10 comments

Comments

@shige0102
Copy link

shige0102 commented Jun 18, 2018

Hi

Describe the bug

  1. Can not work -U option.
  2. Can not work user:password@proxyhost of -x option.

Environment
Use an authentication proxy server.

Curl command line

  1. -U user:password -x http://proxyserver:8080 https://www.google.com
  2. -x http://user:password@proxyserver:8080 https://www.google.com

libe.txt

@libetl
Copy link
Owner

libetl commented Jun 18, 2018

I need to find a sample proxy server that requires authentication. Do you have one that is available publicly ?

@libetl
Copy link
Owner

libetl commented Jun 18, 2018

maybe that one : https://github.com/liggitt/auth-proxy

@libetl
Copy link
Owner

libetl commented Jun 18, 2018

quite stupid mistake in the code.
I wrote Proxy-Authenticate (which is a response header) instead of Proxy-Authorization.

I will patch right away.

@libetl
Copy link
Owner

libetl commented Jun 18, 2018

Thanks for the notice.

libetl added a commit that referenced this issue Jun 18, 2018
@libetl
Copy link
Owner

libetl commented Jun 18, 2018

Tested locally, cannot write an unit test unfortunately.

@libetl
Copy link
Owner

libetl commented Jun 18, 2018

pushing 0.0.18

@shige0102
Copy link
Author

Hi

Thanks for the response and the patch .
I retired the new source.
HTTP proxy is it work. But HTTPS proxy is not work.
In HTTPS, the header set in HttpRequestBase.setConfig is not set to the proxy.
set the Proxy-Authorization with setDefaultHeaders.

It does not work when setting authentication information with the -x option.

-x http://user:password@proxyserver:8080 https://www.google.com
Caused by: java.util.concurrent.ExecutionException: org.toilelibre.libe.curl.Curl$CurlException: java.net.UnknownHostException: user:password@proxyserver
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at org.toilelibre.libe.curl.Curl.curl(Curl.java:35)

@libetl
Copy link
Owner

libetl commented Jun 19, 2018

new unit tests :

    @Test
    public void proxyWithAuthentication2 () {
        //given
        CommandLine commandLine = ReadArguments.getCommandLineFromRequest (
                "-x http://localhost:80/ -U jack:insecure http://www.google.com/");

        //when
        HttpUriRequest request = HttpRequestProvider.prepareRequest (commandLine);

        //then
        assertEquals (request.getFirstHeader ("Proxy-Authorization").getValue (),
                "Basic amFjazppbnNlY3VyZQ==");
        assertEquals(((HttpGet)request).getConfig().getProxy().toString(), "http://localhost:80");
    }

    @Test
    public void proxyWithAuthentication3 () {
        //given
        CommandLine commandLine = ReadArguments.getCommandLineFromRequest (
                "-x http://jack:insecure@localhost:80/ http://www.google.com/");

        //when
        HttpUriRequest request = HttpRequestProvider.prepareRequest (commandLine);

        //then
        assertEquals (request.getFirstHeader ("Proxy-Authorization").getValue (),
                "Basic amFjazppbnNlY3VyZQ==");
        assertEquals(((HttpGet)request).getConfig().getProxy().toString(), "http://localhost:80");
    }

libetl added a commit that referenced this issue Jun 19, 2018
@libetl
Copy link
Owner

libetl commented Jun 19, 2018

I did not work with https proxies yet.

But it will work with the http://user:password@hostname from the version 0.0.19

@libetl
Copy link
Owner

libetl commented Jun 27, 2018

closing since no activity in the feed for one week.
Please reopen in case where you are not satisfied with the assistance.

@libetl libetl closed this as completed Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants