SecureServer is a Java web application deployed on Apache Tomcat demonstrating secure HTTPS communication using SSL certificates. This mini-project shows how to configure a local server with HTTPS, generate SSL certificates, and redirect HTTP traffic to HTTPS for secure communication.
- Simple Java web application running on Tomcat
- HTTPS enabled using self-signed SSL certificate
- HTTP ➞ HTTPS automatic redirection
- Gradle build for easy compilation and deployment
- Demo-ready for local testing
- Java JDK 17 or above
- Apache Tomcat 9+
- Gradle 8+ (for building the project)
- Basic understanding of web servers and SSL/TLS
git clone https://github.com/WHitE-TITaN/SecureServer.git
cd SecureServergradle buildThis generates the .war file in build/libs/secureServer.war.
- Download Apache Tomcat 9/10 for Windows
- Install and start the server
- Test by visiting:
http://localhost:8080
Tomcat uses a Java Keystore (.jks):
mkdir C:\tomcat
keytool -genkey -alias tomcat -keyalg RSA -keystore C:\tomcat\mykeystore.jks -keysize 2048 -validity 90Command format - -genkey -alias ServerType(tomcat, appache etc) -keyalg (algorithm to be used) -keystore (location to store the certificate) -keysize (size of the key) -validity (certificate validity date in days)
Fill in:
- Keystore password
- Name (CN)
- Organization (O)
- City (L)
- State (ST)
- Country (C)
This creates mykeystore.jks.
Important: This command needs a c:/tomcat directory to store the keystore. !Ensure the directory exists before running the command.
- Open
TOMCAT_HOME/conf/server.xml - Uncomment the HTTPS connector section and modify:
<Connector port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150"
SSLEnabled="true"
scheme="https" secure="true">
<SSLHostConfig>
<!-->certificateKeystoreFile attribute contain the location the certificate
the default location will be C:\tomcat\mykeystore.jks<-->
<Certificate certificateKeystoreFile="C:\tomcat\mykeystore.jks"
certificateKeystorePassword="YOUR_PASSWORD"
type="RSA" />
</SSLHostConfig>
</Connector>- Save and restart Tomcat.
- Copy
secureServer.warfrombuild/libsto:
TOMCAT_HOME/webapps/
- Tomcat will auto-deploy it.
Or change the server.xml to point to the application or cloned location.
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/location" path="/" reloadable="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>Open browser:
https://localhost:8443/
- Browser shows a padlock (self-signed certificate warning)
- Click Advanced → Proceed
- Your application is now running securely over HTTPS
Add this to your app’s web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>SecureApp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>Now, any HTTP request automatically redirects to HTTPS.
SecureServer/
│
├── build/ # Gradle build output
├── src/
│ ├── main/java # Java source code
│ └── main/webapp # HTML/CSS/JSP files
├── build.gradle # Gradle build script
├── settings.gradle
└── README.md
- Command prompt generating keystore
- Tomcat
server.xmlSSL configuration - Browser showing HTTPS padlock
- Certificate properties
- HTTP → HTTPS redirect working
- Self-signed certificates are for demo purposes; production should use Let’s Encrypt or commercial certificates
- Gradle simplifies building and managing dependencies
- Project demonstrates TLS handshake, secure communication, and server configuration