Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup Wifi proxy credentials programmatically

The app will be signed with the system signature, so in the end some protected permissions (like android.permission.WRITE_SECURE_SETTINGS) may be granted.

My question is then how to setup credentials globally for a proxy on a particular WiFi network knowing that the app will be signed with system signature?

I can't find any information on how to do this. Based on what can be done in a standard java app, the following code may work :

        System.setProperty("http.proxyUser", usr);
        System.setProperty("http.proxyPassword", pwd);

But, is it the way to set proxy credentials on Android ? Is it going to set proxy credentials globally (i.e. for all apps using default http support) ? (IMO, even if this call works it won't change anything outside process boundary)

I also checked the code of android.provider.Settings.java where I found some properties about global proxy : global_http_proxy_host and global_http_proxy_port but nothing about proxy authentication.

like image 477
ben75 Avatar asked Apr 12 '18 10:04

ben75


People also ask

How do I add credentials to proxy?

In Windows 10 menu, go to Settings (WinKey+I) and search for "Credential Manager". Under Windows Credentials, add a new entry for Windows Credentials. Enter the Proxy Server address (without the port number), your domain user name and the password.

How do I force proxy authentication?

Option 1: Force proxy reauthentication by switching to a different proxy server. One option is to switch to a different proxy server. If you change your proxy configuration to point to a new hostname or port you haven't used yet in your current browser session, you'll get a new authentication prompt.

What is PAC URL in WIFI?

A Proxy Auto-Configuration (PAC) file is a JavaScript function that determines whether web browser requests (HTTP, HTTPS, and FTP) go directly to the destination or are forwarded to a web proxy server.


2 Answers

Android uses System.setSystemProp to set the proxy in frameworks/base/core/java/android/net/Proxy.java

I guess you can do the same thing if you have system privileges.

I'm unsure if it affects android.webkit though.

like image 148
rds Avatar answered Oct 18 '22 03:10

rds


There's no way to set global proxy credentials in Android. There's simply no structure in the whole AOSP that can hold it.

Unfortunately, I did not manage to find any explanation for this. Relevant Issue Tracker items are not public, comments in the source code are scarce. There's nothing in the developers blog on the issue. Embedded Android by Karim Yaghmour does not shed light on the issue either.

P.S. This answer is based purely on code analysis.

like image 3
Константин Осипов Avatar answered Oct 18 '22 02:10

Константин Осипов