So, if I understand your question correctly:
- You have a web application that can be accessed using cross-origin requests.
- This application will be deployed on local networks, i.e. it will be accessed via a non-public IP address (the machine serving it being in that network, I'll call it "local server").
- You want to protect the link between the client and the local server, preferably using SSL.
You can do that! Make whoever has control of the local server get a SSL certificate for somesubdomain.SomeDomainHeControls.com
, deploy that certificate to the local server, and point that subdomain to the local IP. When the application is then accessed via that address, you will not get any warnings and the connection will be secured. As long as the client only accesses your application using that domain, this is secure, since only the owner of the server has access to the key.
If you control the local server yourself (noone can extract the private key), you can simply get a wildcart certificate for *.aDomainForThisPurposeThatYouControl.com
, and create a subdomain for each deployment, pointed to the appropriate IP.
If you do not control the local server and whoever does cannot get his own certificate, you could get individual certificates for them. This would mean you create deployment1.aDomainForThisPurposeThatYouControl.com
, point it to the local IP, create a regular, single-host certificate for that name, and install it on the local server. As a safety precaution, do not use that domain for anything else, since you have given out private keys for hosts on this domain.
You could also host the application itself on an external server under your control, if the local networks have access to the internet. Deploy regular SSL to that server. After the application itself has been loaded from the external server securely, it can make plain HTTP requests to get data from a local server. This will trigger a "mixed content" warning, but no SSL error. You can then use JavaScript-based encryption to protect the data. For example, if you only want to protect data going from the client to the server, your external, trusted server could provide the client with trusted JS crypto libraries and the RSA public key of the internal server (via the SSL-authenticated connection), then you just encrypt your data on the client side before sending it over plain HTTP. In theory, you could even create a SSL client in JavaScript, provide the script and a trusted server certificate to the client, use a HTTP or WebSockets tunnel, and over this tunnel, run your own SSL connection between the local server and the JavaScript client. This is, of course, not very practical, but secure (since the JS is downloaded via a secure connection). You can also just load a small JavaScript from the trusted server, which then downloads the rest from the local server, verifies a signature/hash, and executes it. Megaupload is doing something like that.