Possible Duplicate:
network communication encryption in java
I am designing a client server application. I want the whole session to be encrypted. I was thinking the following precudure to do that(using RSA for public-key encryption and AES-128 for symmetric encryption):
Client connects to server and send a 'hello' message. Server responds with it's public key. Client generates an 128-bit AES key, and sends it encrypted with the server's public key. The rest of the application protocol is encrypted using the AES key.
Is this logic ok? Are there any flaws? Will it be okay or it's better to use SSL? Basically what i am concerned are replay attacks and mitm.