Built from scratch multithreaded HTTPS web server that was implemented with Java, using SSLServerSocket, ExecutorService thread pooling and javax.net.ssl (TLSv1.3 / TLSv1.2) backed with a local PKCS#12 keystore (keystore.p12).
- OS: Windows (tested in PowerShell)
- JDK: JDK 25 (LTS) (
java,javac,keytool) - Working Directory:
Project root (\)
To create a self signed PKCS#12 keystore for localhost / 127.0.0.1:
keytool -genkeypair `
-alias localhost `
-keyalg RSA `
-keysize 2048 `
-storetype PKCS12 `
-keystore keystore.p12 `
-storepass changeit `
-keypass changeit `
-validity 365 `
-dname "CN=localhost" `
-ext "SAN=dns:localhost,ip:127.0.0.1"javac HttpsServerApp.java
java HttpsServerAppBy default the server will listen at https://localhost:8443.
GET /— Returns200 OKHTML including the worker thread name handling the request.GET /health— Returns200 OKJSON ({"status":"up"}).POST /echo— Returns200 OKechoing the request body.- Mismatched HTTP methods on known routes — Returns
405 Method Not Allowedwith allowed method details. - Unknown routes — Returns
404 Not Found.
curl.exe -k -i https://localhost:8443/
curl.exe -k -i https://localhost:8443/health
curl.exe -k -i -X POST -d "hello tls server" https://localhost:8443/echo
curl.exe -k -i -X POST https://localhost:8443/health
curl.exe -k -i https://localhost:8443/unknown1..6 | ForEach-Object {
Start-Job { curl.exe -k -s "https://localhost:8443/?req=$using:_" }
} | Receive-Job -Wait -AutoRemoveJob- Method & Variable Typos / Mismatches: Fixed the
createSslServerSocketFactorynaming,sslSocketsome pattern/handshake handling, aHashMapstypo, the request body loop variables (totalRead/toRead),sendResponseargument mismatching andrepsonseHeaderstypo. - PKCS#12 Keystore Load (
toDerInputStream rejects tag type 107): Removed stale/malformedkeystore.p12bytes and regenerated a valid DER-encoded PKCS#12 keystore withkeytool. /healthRoute Matching: needed to fixerouteRequestto match/healthinstead of jsut showing the/echoonGETthen recompiled and restarted the server.- HTTP Status Line (
Unsupported HTTP/1 subversion in response): Added missing (white)space after"HTTP/1.1 "in thesendResponseso status lines format asHTTP/1.1 <statusCode> <reason>to align woth JAVA requirements.
- The Java™ Programming Language, Fourth Edition by Ken Arnold, James Gosling, and David Holmes (
THE Java™ Programming Language, Fourth Edition By Ken Arnold, James Gosling, David Holmes.pdf) — is included for historical, language reference context.