This project demonstrates a simple SSL (Secure Sockets Layer) based client-server application in Java. It ensures secure communication between a server and a client by encrypting the transmitted data using Javaβs built-in SSL capabilities.
This application sets up a server that listens over SSL and a client that connects securely to it. Both sides exchange messages over an encrypted channel, providing confidentiality and integrity.
- Java JDK (8 or later)
- VS Code with Java Extension Pack (recommended)
- Terminal access
The keystore is required by the server to authenticate itself.
keytool -genkeypair -alias serverkey -keyalg RSA -keysize 2048 -keystore serverkeystore.jks -validity 365
Keystore password: password
You can leave other prompts as default or fill in accordingly.
Navigate to the project directory and run:
javac SSLServer.java SSLClient.java
java SSLServer
The server will listen for incoming SSL connections on port 4444.
java SSLClient
Upon successful connection, messages will be exchanged securely.
SSLContext: Sets up the secure socket layer configuration.
Keystore: Stores the server's private key and certificate.
TrustManager: Used on the client side to accept the serverβs certificate (here, it accepts all for demo purposes).
Encrypted Communication: All data between client and server is encrypted using SSL.
This project is for educational purposes. The client blindly trusts all certificates, which is not recommended for production use.
For real applications, validate server certificates properly using a TrustStore.
Server terminal:
SSL Server is running on port 4444
Client: Hello from Client
Client terminal:
Server: Hello from Server