skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search