titanium-web-proxy icon indicating copy to clipboard operation
titanium-web-proxy copied to clipboard

Do I need to install a new certificate for IOS every time I start the program? Failure without installation?

Open bbhxwl opened this issue 5 years ago • 49 comments

Do I need to install a new certificate for IOS every time I start the program? Failure without installation?

proxyServer.CertificateManager.CreateRootCertificate(false); proxyServer.CertificateManager.TrustRootCertificate(); proxyServer.CertificateManager.TrustRootCertificateAsAdmin(); //File.WriteAllBytes(" ca.cer",proxyServer.CertificateManager.RootCertificate.Export(System.Security.Cryptography.X509Certificates.X509ContentType.Cert));

bbhxwl avatar Dec 18 '19 13:12 bbhxwl

You don't have to create and trust it every time... just create it once, store it somewhere and in the next start set it before you start the proxy.

honfika avatar Dec 19 '19 10:12 honfika

I will, thank you, I want to know, if I don't modify the network data, can I let users do not need trust certificates? Like an HTTP proxy server. What's more, if I want the user to enter the account and password, my server can do the verification code?

bbhxwl avatar Dec 21 '19 14:12 bbhxwl

Yes, of couse it is possible to use proxy without own certificates. In this case you can see in TWP only the HTTP traffic (and you can even modify that) and the encrypted HTTPS traffic.

You mean proxy server authentication? Yes, you can require that from the users.

honfika avatar Dec 21 '19 16:12 honfika

If I do n’t set a certificate and the user uses a proxy, can https work properly? Can I intercept it? I don't want to modify the data, I just want to monitor, I want the user to enter the authentication, but how can I verify the authentication he entered in the code?

bbhxwl avatar Dec 21 '19 16:12 bbhxwl

Yes, it works properly, but you see only the entrypted data. So only the connect request then the data which goes through the tunnel. Not able to see the decrpyted HTTP requests/responses. This is why you need the own certificate. It does not matter whether you want to modify the request or not.

Authentication: Check the proxyServer.ProxyBasicAuthenticateFunc property.

honfika avatar Dec 21 '19 16:12 honfika

What do you mean by your own certificate? Is it to request an SSL certificate for a public website? Or, as in the project, set the root certificate, and then distribute a certificate to the customer for installation? If the customer doesn't install it, there's no way, right?

bbhxwl avatar Dec 22 '19 10:12 bbhxwl

If the customer doesn't install the root certificate, you are not able to see the decrypted traffic... that is the purpose or SSL...

honfika avatar Dec 22 '19 10:12 honfika

Can't I have the HTTP proxy server forward his HTTPS data intact? I don't need a certificate? I checked the related articles on the Internet. The HTTP proxy used by the crawler and the HTTPS protocol supported do not require the customer to install the certificate, which is to forward the data intact

bbhxwl avatar Dec 22 '19 10:12 bbhxwl

You can forward the encrypted stream without installing a certificate... this is what I wrote you 21 hours ago. And it will work properly... (of course you won't see the decrypted traffic in TWP)

So:

1st. DecryptSsl: true Root certificate is needed and it should be trusted on the customer device HTTP: forward, access the not encrypted data (for example HTML source), modify HTTPS: forward, access the decrypted data (for example HTML source), modify

2nd: DecryptSsl: false No certificate needed in TWP or in the client device HTTP: forward, access the not encrypted data (for example HTML source), modify HTTPS: forward, access only the encrypted data (no HTML source), not possible to modify

honfika avatar Dec 22 '19 13:12 honfika

Don't do business, brother. I understand. Because my English is poor, I can only use translation software. I may not understand something, but if I write code, I will understand what I say. For example, decryptssl: false, I get it. Thank you very much. If I knew what the Chinese meaning of decrypt was, I might have understood it for a long time, but it's a pity. Thank you.

bbhxwl avatar Dec 22 '19 13:12 bbhxwl

By the way, I'll ask you again. Maybe I have a little more questions. Excuse me, can the SDK use a secondary agent? For example, the first time a user connects to IP 6.6.6.6, the actual IP I forward through the server is 1.1.1.1, and the second connection is automatically forwarded to 2.2.2.2, but the IP of each connection is 6.6.6.6

bbhxwl avatar Dec 22 '19 14:12 bbhxwl

What is the host in the HTTP request in the first and 2nd query?

honfika avatar Dec 22 '19 14:12 honfika

I mean, I use titanium.web.proxy to build an HTTP proxy. The user connects to my HTTP proxy. After receiving the request, my server will use the HTTP proxy to server B again through the transit method

bbhxwl avatar Dec 22 '19 14:12 bbhxwl

Sorry, I dont understand.

TWP is running on machine 6.6.6.6, right?

Client has for exmaple 1.2.3.4.

Client loads a webpage on 1.1.1.1 through TWP proxy (6.6.6.6), right?

Them client loads a webpage on 2.2.2.2 through TWP proxy (6.6.6.6), right?

honfika avatar Dec 22 '19 14:12 honfika

Yes, the client 1.2.3.4 connects to the server 6.6.6.6, the server connects to the 1.1.1.1 server, and then receives the data and sends it back to the client so that the user can see that the ip displayed by him is not connected by himself server.

bbhxwl avatar Dec 22 '19 14:12 bbhxwl

Ok, and then the clients loads a webpage on 2.2.2.2.... what is the problem?

honfika avatar Dec 22 '19 14:12 honfika

I mean to be an HTTP proxy that dynamically changes IP. , so the IP of the primary server connected by the user is the same, but the IP may change every time the user accesses.

bbhxwl avatar Dec 22 '19 14:12 bbhxwl

there is no hostname for 1.1.1.1, right?

So the client connects to http://1.1.1.1/xx (through proxy 6.6.6.6)

In this case you can change the request uri in the beforerequest handler:

            proxyServer.BeforeRequest += onRequest;

        private async Task onRequest(object sender, SessionEventArgs e)
        {
            if (e.HttpClient.Request.Url.Contains("1.1.1.1"))
            {
                e.HttpClient.Request.Url = e.HttpClient.Request.Url.Replace("1.1.1.1", "2.2.2.2");
            }
        }

But this is only for HTTP... for HTTPS you need DecrpytSsl true

honfika avatar Dec 22 '19 14:12 honfika

No, I don't mean to modify the URL. I mean to set the HTTP proxy on server 6.6.6.6 and connect to another server proxy 8.8.8.8

bbhxwl avatar Dec 22 '19 15:12 bbhxwl

Double layer HTTP proxy

bbhxwl avatar Dec 22 '19 15:12 bbhxwl

It is called UpStreamProxy:

proxyServer.UpStreamHttpProxy = new ExternalProxy() { HostName = "2.2.2.2", Port = 8888 };
proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "2.2.2.2", Port = 8888 };

honfika avatar Dec 22 '19 15:12 honfika

If you want to count the traffic of each request, you need to calculate each request+

Is the amount of response data?

bbhxwl avatar Dec 22 '19 16:12 bbhxwl

It is called UpStreamProxy:

proxyServer.UpStreamHttpProxy = new ExternalProxy() { HostName = "2.2.2.2", Port = 8888 };
proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "2.2.2.2", Port = 8888 };

This project is so powerful. I've written everything. I've learned it. Thank you.

bbhxwl avatar Dec 22 '19 16:12 bbhxwl

This external agent is set globally, right? Can't be modified one time?

bbhxwl avatar Dec 22 '19 16:12 bbhxwl

There is a GetCustomUpStreamProxyFunc function in ProxyServer, so you can dynamically set the proxy for each request.

But I'd like to change this behavior (I'll keep this propety for compatibility in v3.x).. i plan to add a new propety somewhere and then it will be possible to set the proxy in the beforerequest event handler.

For counting the traffic there are 2 events in the SessionEventArgs base class: DataSent and DataReceived. You can sum the byte counts in them.

honfika avatar Dec 22 '19 16:12 honfika

If GetCustomUpStreamProxyFunc is modified, if two different users concurrently, the proxy request of these two people should be modified, right? Looking forward to your updates.

bbhxwl avatar Dec 23 '19 02:12 bbhxwl

Is this property CustomUpStreamProxyUsed?

bbhxwl avatar Dec 23 '19 02:12 bbhxwl

Sorry, I don't understand your question.

You can return the upstream proxy you want to use from GetCustomUpStreamProxyFunc for each request.

CustomUpStreamProxyUsed contains the propxy which was used by TWP.. it is readonly.

honfika avatar Dec 23 '19 07:12 honfika

I see. Now we can't use external proxy for a single request

bbhxwl avatar Dec 23 '19 08:12 bbhxwl

In the onrequest event

bbhxwl avatar Dec 23 '19 08:12 bbhxwl

Yes, but you can sue the GetCustomUpStreamProxyFunc proeprty. It receives the current session arguemnts and you can return different upstream proxy for different requests.

honfika avatar Dec 23 '19 08:12 honfika

Yes, but you can sue the GetCustomUpStreamProxyFunc proeprty. It receives the current session arguemnts and you can return different upstream proxy for different requests.

It is not clear whether it is possible to modify this external proxy in onrequest, not to modify the global external proxy in onrequest. Is there any code I can refer to? Are you American? Generally, what chat tools do you use? I would like to find a group to learn from. I also saw a project https://github.com/ThrDev/Socks5 if it can be compatible with twp.

bbhxwl avatar Dec 23 '19 09:12 bbhxwl

GetCustomUpStreamProxyFunc is a functio nwhich is caleld for each request. You can return different proxy for each request. You don't have to modify the global upstream proxy.

I' hungarian. I have Skype.

honfika avatar Dec 23 '19 09:12 honfika

QQ图片20191223220553 The whole code is like this, is it OK? No other special settings, right?

What is your Skype account? I want to add you as a friend

bbhxwl avatar Dec 23 '19 14:12 bbhxwl

No, the GetCustomUpStreamProxyFunc should set to your own function, and that function should return the proxy server.

Please check the sample project, everyting can be found there: https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Skype: honfika_2

honfika avatar Dec 23 '19 15:12 honfika

Arg parameter in ongetcustomupstreamproxyfunc,

Arg.clientendpoint.address gets the IP address of the user,

Arg.httpclient.request.requesturi get the URL currently accessed by the user, right? Then according to my own needs, return to different external agents, am I right? In the ongetcustomupstreamproxyfunc method, is every onrequest event the ongetcustomupstreamproxyfunc will be activated? Every request, it should be entered into this function, right?

bbhxwl avatar Dec 24 '19 06:12 bbhxwl

If you don't want to return the external agent in ongetcustomupstreamproxyfunc, you can return null?

bbhxwl avatar Dec 24 '19 06:12 bbhxwl

Yes, eveery requeset will call this function. Yes, you can retrn null.

honfika avatar Dec 24 '19 07:12 honfika

In onbeforetunnelconnectrequest, can you know whether the other party has installed the certificate? e.IsHttpsConnect? e.IsTransparent? e.IsHttps?

bbhxwl avatar Dec 24 '19 14:12 bbhxwl

No, you don't know that.

honfika avatar Dec 24 '19 15:12 honfika

Do you know why cer files are imported into Android 7.0 or above system certificates, and why they don't work?

openssl x509 -inform DER -in cacert.der -out cacert.pem openssl x509 -inform PEM -subject_hash_old -in cacert.pem Modify the file name to 3dcac768.0

Put it in / system / etc / security / cacerts/ The system certificate can detect the certificate, but the browser still can't access the HTTPS protocol, and the app can't grab the HTTPS

QQ图片20191225150046

bbhxwl avatar Dec 25 '19 07:12 bbhxwl

Sorry, I don't know. I never tried to use TWP from Android.

honfika avatar Dec 25 '19 07:12 honfika

I have a suggestion that if the socket monitored by tcp_listen does not conform to the HTTP proxy protocol, request to return a tcplistener to me, which has made me the same port, compatible with HTTP and Socks5 protocol. Use with https://github.com/bbhxwl/socks5server project. I want to build a proxy server system

bbhxwl avatar Dec 26 '19 11:12 bbhxwl

You mean return the TCPClient (or the Socket object) to the user in an event? for example

public event EvenrHandler<UnsuppoortedConnectionEventArgs> UnsupprtedConnection; in proxyServer class?

I can do that, but the first some bytes will be lost (what was already read by TWP to derermine whether it is a valid HTTP(S)/SOCKS request or not). Is that OK?


Another: I don't understand what should I do with your socks library. Socks 4/5 support was already added to TWP.

honfika avatar Dec 26 '19 16:12 honfika

Twp supports Socks5?

bbhxwl avatar Dec 26 '19 16:12 bbhxwl

I just want to make a proxy server authentication management system. At present, http can be perfectly completed with your SDK. At present, .net core cannot perfectly implement socks5 proxy. If 2 protocols can be integrated in a port, it is perfect.

bbhxwl avatar Dec 26 '19 16:12 bbhxwl

Yes, TWP now supports SOCKS4 and 5 (with username/password authentication in the latest beta package)

honfika avatar Dec 26 '19 16:12 honfika

When was Socks5 support added? These days? When will the stable version be updated? There's only beta right now, right?

bbhxwl avatar Dec 27 '19 04:12 bbhxwl

Yes, some days ago.

Stable version already supports SOCKS5. (without authenticateóion)

SOCKS5 username/passworw authentication was added in beta.

I'll release stable in this year.

honfika avatar Dec 27 '19 07:12 honfika