views:

343

answers:

9

I have a website hosted on a provider which doesn't give me with a fixed ip adress so I cannot use https. I would like to edit some page using a webform but in a secure fashion.

The client would be an iphone type device, so a java or flash applet would be out of the question.

  • Is there a way to still have a secure connection between the server and the browser using only javascript in the browser ?

The language on the server is currently php but it could be ruby, python , perl or lua.

+1  A: 

I would say the answer is no. The reason being is that without https, all traffic is unencrypted plain text. Therefore, any encryption algorithm or key exchange on the client side would be readable by anyone. I could be wrong though...I've never tried it.

Rich
Well the key exchange has to work unencrypted regardless of protocol..?
Oskar Duveborn
A: 

How would it be possible to use Javascript? In order for the browser to execute the javascript, it would have to first download it from the (previously stated) insecure server. HTTPS is a server/client protocol, so if you can't implement with the server itself, you won't be able to implement it at all.

All you need for HTTPS is a single IP address, so it wouldn't matter if it changed. You should be able to use HTTPS with a dynamic IP, but you might need to talk to your hoster. If your hosting is on a shared server, then it won't work and you'll need a dedicated IP. They aren't that expensive, so maybe you should just shell out the $3/4 a month?

Alex

Alex Fort
You are right. If you are depending on downloading the JS from an insecure server, you are already screwed, because the JS could be changed en route, to be malicious and just send the data unencrypted to somewhere else. Same reason why insecure page posting to secure page isn't secure.
Kibbee
+2  A: 

In theory you could implement some sort of secure communication between the client and server using Javascript and XmlHttpRequests. In practice it sounds like a lot of work and the chances of it being fast and truely secure seem low.

As Alex says above though, even if you managed to implement in JS, you'd still have to serve the JS to the client over an insecure connection, therefore making it all fairly pointless.

Still, crazier things have been implemented in Javascript before...

andynormancx
+10  A: 

Installing a SSL certificate doesn't technically require a fixed IP address - the SSL certificate is tied to the host name (common name). We have often changed IP addresses on our hosts and never changed anything related to the certificates.

That said, you could indeed use JavaScript or the like, but it's not really a nice solution - it'll always smell like a hack.

Phil Reif
+3  A: 

You could use some form of public key encryption implemented in javascript:

  • You give client side the form, your public key, and a js encryption library
  • On submission, js kicks in an encrypts the form payload
  • You decrypt with your private key

The would prevent anyone from sniffing your sensitive info on the wire, but doesn't provide any protection against a man-in-the-middle attack. SSL makes such an attack a little trickier to pull off, but not impossible.

Paul Dixon
How do you prevent sniffing sensitive data on the wire, but not a MITM attack? Aren't they one and the same?
Kibbee
Not really - an unencrypted stream doesn't need a MITM attack to read it after all. Mind you, it's not as if SSL provides much more MITM mitigation, but it is a little harder.
Paul Dixon
+1  A: 

It is theoretically possible, provided you can control the client and (for example) have trusted javascript there which is not downloaded from the server. I could elaborate but anything on these lines is a PITA and error prone compared to using https.

Also it should not be necessary to have a fixed IP - do you have a domain name?

frankodwyer
In the iPhone case mentioned in the question having trusted Javascript that is not downloaded from the server is not possible.
andynormancx
Yes if it's a web app - but it's not clear from the question if a native app is an option. If not then what the OP wants to do isn't possible unless active attacks are not a concern.
frankodwyer
+3  A: 

Not in the traditional sense, no but there are a few options:

  1. Get better hosting. You could have a VPS with a fixed IP for $20/month. Certificate for $30 a year. Fairly cheap for people that need the security.

  2. You could encrypt the form data using javascript and PGP. This is cheap (and it'll look it to your users) but it should keep your data safe enough.

  3. There might be third parties out there that allow for form submission through their servers (and by extension) their certificates. You and your users would have to trust them not to abuse the data though.

Oli
+1. Getting a better hosting provider is probably the best option. What kind of crappy hosting provider doesn't support fixed IPs and SSL certs?
Kibbee
A: 

SSL operates off the domain name, not an IP address. As long as you have and own a domain name, and have a provider willing to open port 443 and install the certificate you purchase for your site, you can do HTTPS.

That being said, assuming you can't do it, look into SRP:

From the site:"SRP is a secure password-based authentication and key-exchange protocol. It solves the problem of authenticating clients to servers securely...In addition, SRP exchanges a cryptographically-strong secret as a byproduct of successful authentication, which enables the two parties to communicate securely."

They have a Javascript examples. You'd use the byproduct to encrypt the data over the wire.

However, like most posters, you'd probably be better off moving to a new provider.

alphadogg
A: 

It's almost 2 years later, but there's an opensource SSL/TLS implementation in JavaScript now. However, it currently relies on Flash to provide raw socket access... so unless the application is going to run on an android phone rather than an iphone, it might not be all that helpful.

http://github.com/digitalbazaar/forge/blob/master/README

dlongley