tags:

views:

185

answers:

2

I'm currently attempting to implement having a (signed) applet communicate to a server program via SSL. I have found the right kind of incantations to create key stores for the client, the client's trust manager, and the server. This allows me to create compatible SSL contexts on the client and the server.

However, as it stands, this setup would require an admin to create the key stores and then distribute them to the client and server machines. I would like to avoid having to make people configure the system.

So as a fallback, is it possible to generate a client-side key automatically and use a "lobotomised" trust manager to create compatible SSL contexts without any configuration?

+2  A: 

If it's your well-known server that you're communicating with, and SSL is causing you headaches in one way or another, then you might also consider the option of just ditching SSL.

SSL is really designed to solve the problem of talking to an "unknown" server, hence the complications of certificates and protocol negotiation. If the problem you're trying to solve is just sending some encrypted data to a known server, then you can always generate an RSA key pair, stick the public key in a file in the jar, and use the boring old cryptography API to send and interpret your data. Just a thought...!

Update: I should have mentioned, that I'm assuming in the first place that you have a trusted means of installing the software on your clients. A commenter has rightly pointed out that if this isn't the case, then distributing the public key this way is subject to a man-in-the-middle attack (whereby the MITM gives you a doctored jar with the public key for THEIR eavesedropping server). I had assumed that this wasn't the thread model you were trying to protect against, and that clients were being given the jar from a trusted source (e.g. an engineer from the company installs the program on their system). If they're downloading the jar over the Internet, being sent it via e-mail etc, then you'd still want to sign the jar with a CA-issued certificate, even though within your actual code, you may use the public key you distributed in the jar to connect.

Neil Coffey
That's the solution I'm currently heavily leaning towards. In fact, the client and server could generate key pairs, exchange public keys, then use RSA to communicate symmetric encryption keys to use for sending the data.
Zarkonnen
OK, so yes you would in practice use RSA to send a secret key. But if you generate RSA keys per session, you're back to the problem of knowing that it's YOUR server that you're talking to. If you just use a fixed key pair, you know it's your server (because you've presumably not given the private key to anyone else). Unless you really want to authenticate the clients (which is generally a bit difficult and pointless in practice), you only need the one key pair-- private key on server, public key to clients.
Neil Coffey
How do you know that Mallory didn't substitute a patched jar file with her public key in it? Trying to improvise server authentication is doomed. Give up, or get a legitimate certificate.
erickson
On the client, you may not. It depends a little on what thread model you're trying to protect against. At the end of the day, if Mallory can doctor your client, she can doctor your client, be that doctoring your jar or doctoring your certificate store...
Neil Coffey
Sure, it depends on the threat model. However, users control their client and can presumably assure its security; it is a trusted environment. Using SSL properly allows them to connect two such trusted environments over an untrustworthy network (where Mallory resides), and that's pretty valuable.
erickson
+1  A: 
erickson
So in short, your answer is: "don't do that because it can't be secure". Which works for me - as long as I can go and say to the end-user: "you *have* to distribute the keys and certificates, otherwise can't be secure".
Zarkonnen