0

I am trying to make proxy settings via a fake vpn in my react native android application. I am giving proxy settings into builder thanks to VpnService with android.net.ProxyInfo package. But the proxy I am using has an auth requirement. I guess ProxyInfo doesn't take a credentials directly. How can I do this?

When I enter any site with the current settings, it gives me the following message.

not auth or invalid auth credentials. make sure to update your proxy address, proxy username and password

I tried with the other method below but I can't say it worked. when I tried to open the site my browser asked me for username and password with a popup, but the popup is so unstable that I can't even type it.

Authenticator.setDefault(new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                Log.d("VPNService", "VPN Auth Settings...");
                return new PasswordAuthentication("username", "password".toCharArray());
            }
        });

I should add that this proxy will not work specifically in some places. So as long as the vpn works, it will be active, a global method is needed, not just an application-by-application effect.

What I need is how can I give auth info when using proxy with vpn?

Thanks in advance for the explanatory answers

2 Answers 2

1

TLDR

I'm going to say "no".

Here's why:

I looked at the docs -> https://developer.android.com/reference/android/net/ProxyInfo

It does not let you provide proxy-auth, which is traditionally a username + password.

It does offer using proxy auto config (.pac), but that config format also doesn't allow you to declare proxy auth.

History

This technology comes from the browser wars Netscape vs. IE 5/6 era. This was even before HTTPS was commonplace, much less required. Both HTTP auth and Proxy (over HTTP) auth used the Basic Auth style, which was just in the headers.

There were concerns about letting users save passwords into browser configs, so for a long time, both auth could only be entered via an interactive prompt.

This was also before password management features were common, but single-signon was available. So users often only needed to answer a proxy-auth challenge once a browser session, it was annoying, but not unbearable.

It looks like this API has not been extended since those days.


I'll let this sink in before I suggest workarounds in the comments.

Sign up to request clarification or add additional context in comments.

4 Comments

but when we look at proxy apps for android, they take password and username and establish a connection with vpn. what do you think is the logic of this? i really need a solution. @benc
If you can remove code that might interfere with the popup, that is probably the best solution. The other solutions would probably be too hacky to trust.
The popup window may be provided by the browser. The real problem is that the login doesn't work. I wonder how the people who did this did it. Even if I close the popup myself it will give auth error.
Can you manually test this in a browser config? Many admins don't want to use the original proxyauth because of its limitations.
1

I was able to do this using the tun2socks package. you can add the source code as a library to your code in .aar file format. then impelement it in app/buildgradle. you can now use the library in a vpn service. with key and engine values http / https / socks5 will be available. besides that it passes through proxy checkers without any problem. proxy info is not very good at this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.