Determining browser Proxy setting in NPAPI to download page SSL certificate - c++

Users could have connections through proxies. Some using system-wide proxy settings, others browser-wide proxy.
On Windows for example you could have the system proxy settings as well as proxy settings for Firefox or Chrome alone. Therefore relying on system proxy settings is not reliable.
The only logical solution is to use whatever proxy settings the browser loading my plugin is using. If Firefox is loading my plugin and it has some proxy settings, my plugin should connect using these settings as well. I need my plugin to download the SSL cert of the page in which the plugin is loaded (for further verification..etc).
Is there some way to do that in NPAPI or I must use APIs like Windows WinInet or WinHTTP, or OpenSSL for Linux and Mac? If I have to do so, then how can I let my plugin use whatever proxy settings the host browser is using? I am checking out NPN_GetValueForURL, but I don't think it has good compatibility and good browser interop.
Thank you guys!

I'm pretty sure that NPN_GetURLNotify() will use the browser's proxy settings. It would be pretty crazy if it did not.
Update
If you're writing an NPAPI-based plugin, you need to use the NPN_Get/Post functions to do HTTP requests. That will use the host's proxy settings, cookies, etc. These functions exist for this reason; I don't know why you would use Wininet or roll your own instead.
Looking through about:config, it appears Firefox stores the proxy settings in network.proxy.*. You can access these settings programmatically via the Preferences Service. I suppose you could configure Wininet to behave the same, but you still have the cookie problem.

Related

Set system proxy && authentication in C++ on Windows

Is there a way in C++ to set the Windows system proxy with authentication credentials so it would affect all running programs(browsers, etc...) immediatly but:
Not requiring restarting any browser
Not requiring browser-reauthentication
I am looking really for a system level pre-authenticated proxy.
Thank you for any help. Ask any questions if something is unclear.
Using: c++11, Windows 7
EDIT 1: I need to set this programmatically, so please do not suggest any manual actions.
EDIT 2: Partially acceptable is a way how to set proxy programmatically without pre-authentication but still keeping 1. requirement (Not requiring restarting any browser)
System-level proxy settings are located in registry under \Software\Microsoft\Windows\CurrentVersion\Internet Settings hive in HKLM for all users and HKCU hive for current user.
There is an official instruction how to change it via REG file, you does not need to write any code.
But the main problem is: any application may have its own proxy settings, where it 1) can prefer system level settings but allow to override it by user, 2) not using system settings at all.
In corporate environments this problem solves as:
Internet gateway not allowed directly access to external network any computer except proxy server (Microsoft ISA/Forefront Web Proxy)
Proxy settings in registry are forced to all computers via Group Policies
If user need to run application which can not use system-wide proxy settings - it need to install ISA Firewall Client which intercepts all traffic and authenticate it on the ISA proxy.
So when you use full Microsoft software stack - you still not need to write any code :-)
Moreover, ISA Firewall Client uses undocumented Windows features and it will be too hard to write something to replace it with your own "C++11" skills.

Secure browsing is not supported in my app

I have an old application that I'd like to get running again. I've updated the Facebook PHP-sdk to the latest version (I think) and everything is working for most users. Except those using secure browsing.
My app simply tell me that:
This application does not yet support secure browsing (HTTPS).
How do I fix this? I've looked though all the settings in the app-page and I can't figure it out.
You need to purchase and setup an SSL certificate and then plug your https url into your app's settings page. See their migration guide where it says this is now required.

Is it possible to embed a HTTP server in a Google Chrome extension?

Do you think it would be possible to embed a HTTP server inside a Google Chrome extension?
I've seen other Google Chrome extensions execute native code and apparrently they do it by using NPAPI, but I have no idea what that is. And it's really freaking me out, as I'm no C++ expert or anything like that. So I feel a little stuck now and that's why I'm asking for help.
Specifically, I want to create an extension for Chrome with features similar to Opera Unite. For those who don't know what I'm talking about: Opera Unite is basically a zero-conf web server bundled with the browser. I don't want to use it for the same things Opera does, but I like the concept.
I was thinking about using something like node.js inside the browser to create a simple web interface to control some stuff in the browser. Think of it as a remote control for the browser. If node.js isn't possible I'd like to use lighthttpd or something similar. The technology really doesn't matter as long as it allows me to receive commands over HTTP.
But how do I take an existing web server and make a NPAPI plugin out of it?
Clarification: I'd like any browser to be able to communicate with my extension. Especially I want mobile devices like Android or the iPhone to be able to remote control the browser. Is there any other way to accomplish that except with a HTTP server?
Another update: I think the easiest way to do this would be to use a relay server on the web like Pusher or some self-created service. But I don't like this approach because it requires constant internet access and because it's a paid service.
Thank you all!
If you want to do a remote control for the browser, would something like HTML5 WebSockets work for you?
http://www.html5rocks.com/tutorials/websockets/basics/
You can have an external "remote" server that your extension listens to via WebSockets. If you want to host a webserver via extensions. You would need to use NPAPI, there are many C++ libraries out there (Google search) that can do a simple webserver. But I would rather use WebSockets communicate to an external server which will provide you anything you want.
But if you insist, you would need to learn C++, NPAPI, there are many examples online regarding NPAPI.
Here is another web server implemented with chrome.socket: https://github.com/kzahel/web-server-chrome. The server example linked to in chrome-app-samples is actually really buggy and will lock up if you e.g. hold down Ctrl-R on a page served by it.
Here is info on making a web-server in a Chrome app:
https://developers.google.com/live/shows/7320022-5001

C++ change Opera proxy settings

I'm writing an http proxy program in C++ and I need it to automatically configure the default browser proxy settings to use my proxy. With IE i can just modify the registry, Chrome has a command line parameters that can be used, firefox has the prefs file, but I can't figure out how to do it for Opera. It needs to be compatible with all versions, so PAC files are out of the question. Any help is appreciated.
Just in case you had problems with with IE, apparently on Windows 7 you can't just modify the registry.

How can I make networking work in my WinCE app without launching IE first?

I have a simple WinCE network application (in C, Win32 APIs). I find that networking doesn't seem to work unless I launch IE (or another network app) first. I assume that IE is setting up my network interface in some way.
How can I do this for myself?
Might I need to display a list of available interfaces to the user (eg. WiFi/Ethernet/3G)?
Thanks.
All I know is that Internet Explorer uses WinInet (wininet.dll) for its networking, and you can too. WinInet is a MS API for working with http and ftp protocols. Many of the settings on the "Internet Options" control panel applet are actually WinInet settings (e.g. for dealing with cookies, setting up proxies on LANs, and autodial on dial-up networks). I'm 99% sure that anything that IE can do, you can do yourself using the API.
I think the answer might be
InternetAttemptConnect
http://msdn.microsoft.com/en-us/library/aa383996(VS.85).aspx
If by "network application" you mean sockets, then WinCE definitely does not require IE to launch for that to work. You'll need to provide more specifics about what you're trying to do for a better answer than that.
You need to establish a network connection first. You can automate the process using the connection manager API:
Connection Manager
The user can also raise a data connection manually.