This project demonstrates a secure WebSocket communication system using Spring Boot for the backend and vanilla JavaScript for the frontend. It features AES encryption for parameter passing and real-time bidirectional communication.
- WebSocket communication between client and server
- AES encryption for secure parameter passing
- Real-time messaging capabilities
- Robust error handling and logging
- Backend:
- Spring Boot
- Java WebSocket API
- AES Encryption (ECB mode with PKCS5Padding)
- Frontend:
- HTML5
- Vanilla JavaScript
- CryptoJS for AES encryption
WebSocketServer: Handles WebSocket connections, decrypts incoming messages, and manages sessions.CipherUtils: Provides AES encryption and decryption functionalities.- Frontend HTML/JS: Implements the client-side WebSocket connection and encryption logic.
- The client encrypts connection parameters using AES.
- Encrypted parameters are sent as part of the WebSocket URL.
- The server decrypts the parameters upon connection establishment.
- Bidirectional communication is then enabled through the WebSocket.
-
Clone the repository:
git clone [repository-url] -
Navigate to the project directory and build the Spring Boot application:
./mvnw clean install -
Run the Spring Boot application:
./mvnw spring-boot:run -
Open the
index.htmlfile in a web browser to access the frontend.
- Enter the WebSocket URL (e.g.,
ws://localhost:8080/ws) in the frontend. - Provide parameters to be encrypted and sent with the connection.
- Click "Connect" to establish a WebSocket connection.
- Use the message input to send messages to the server.
- This demo uses AES/ECB/PKCS5Padding, which may not be suitable for all security requirements. Consider using a more secure mode like CBC or GCM for production.
- The encryption key is hardcoded for demonstration purposes. In a real-world scenario, implement proper key management.
- Always use HTTPS in production to secure the initial connection.
Contributions, issues, and feature requests are welcome. Feel free to check [issues page] if you want to contribute.
[Specify your license here]
This project is intended for educational purposes and as a starting point for implementing secure WebSocket communications. Always review and adjust security measures for production use.