Problem Statement
The REST API server uses JDK's built-in HttpServer, which has no native TLS support, meaning all API traffic (including authentication credentials, application data, and management commands) is transmitted in plaintext.
Current Behavior
Location: jplatform-rest-api module
- Uses
com.sun.net.httpserver.HttpServer (JDK 21)
- No TLS/HTTPS capability
- API key authentication transmitted unencrypted
- All application management commands in plaintext
Security Risks:
- Credential interception: API keys sniffed on network
- Man-in-the-middle attacks: Traffic modified in transit
- Data exposure: Application configs, logs, metrics visible
- Replay attacks: Captured requests can be replayed
- Failed compliance: PCI-DSS, HIPAA, SOC 2 require encryption in transit
Expected Behavior
All API traffic should be encrypted via TLS 1.2+:
- HTTPS endpoints (not HTTP)
- Certificate-based server authentication
- Strong cipher suites (no weak TLS 1.0/1.1)
- Configurable keystores for certificates
Proposed Solutions
Option 1: Migrate to Netty HTTP Server (Recommended)
Pros:
- Native TLS support
- Better performance (async I/O)
- Production-grade HTTP server
- Stub module already exists:
jplatform-rest-api-netty
Implementation:
// Complete jplatform-rest-api-netty module
ServerBootstrap bootstrap = new ServerBootstrap()
.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
protected void initChannel(SocketChannel ch) {
SslContext sslContext = SslContextBuilder
.forServer(certChainFile, keyFile)
.build();
ch.pipeline().addLast(sslContext.newHandler(ch.alloc()));
ch.pipeline().addLast(new HttpServerCodec());
// ... add handlers
}
});
Option 2: Undertow Web Server
Pros:
- Excellent TLS support
- Lightweight, embeddable
- Used by WildFly/JBoss
Implementation:
Undertow server = Undertow.builder()
.addHttpsListener(8443, "0.0.0.0",
loadKeyStore(), loadTrustStore())
.setHandler(apiHandler)
.build();
Option 3: Reverse Proxy (Workaround)
Pros:
- No code changes
- Offload TLS to nginx/Traefik
Cons:
- Requires separate infrastructure
- Added deployment complexity
- Not suitable for all environments
Documentation approach:
Create TLS_DEPLOYMENT.md with nginx configuration:
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/platform.crt;
ssl_certificate_key /etc/ssl/private/platform.key;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-Proto https;
}
}
Recommended Approach
Phase 1 (Short-term): Document reverse proxy setup in TLS_DEPLOYMENT.md
Phase 2 (Medium-term): Complete jplatform-rest-api-netty module with TLS
Configuration Design
Add TLS settings to ApiServerConfig:
public static class Builder {
private boolean enableTls = false;
private String keystorePath;
private String keystorePassword;
private String keyAlias;
private String[] enabledProtocols = {"TLSv1.2", "TLSv1.3"};
private String[] enabledCiphers = {/* modern ciphers only */};
public Builder enableTls(boolean enable) {
this.enableTls = enable;
return this;
}
public Builder keystorePath(String path) {
this.keystorePath = path;
return this;
}
}
Acceptance Criteria
Phase 1 (Documentation):
Phase 2 (Netty Implementation):
Verification Steps
Phase 1:
- Deploy with nginx reverse proxy
- Test HTTPS endpoint:
curl https://localhost:443/api/applications
- Verify certificate validation works
- Check TLS version:
openssl s_client -connect localhost:443 -tls1_2
Phase 2:
- Generate test keystore:
keytool -genkeypair ...
- Configure Netty server with keystore
- Start server:
mvn exec:java -pl jplatform-launcher
- Test:
curl -k https://localhost:8443/api/applications
- Verify TLS 1.2+:
nmap --script ssl-enum-ciphers -p 8443 localhost
References
Priority: HIGH | Production Readiness Review Score: 8.3/10
Problem Statement
The REST API server uses JDK's built-in
HttpServer, which has no native TLS support, meaning all API traffic (including authentication credentials, application data, and management commands) is transmitted in plaintext.Current Behavior
Location:
jplatform-rest-apimodulecom.sun.net.httpserver.HttpServer(JDK 21)Security Risks:
Expected Behavior
All API traffic should be encrypted via TLS 1.2+:
Proposed Solutions
Option 1: Migrate to Netty HTTP Server (Recommended)
Pros:
jplatform-rest-api-nettyImplementation:
Option 2: Undertow Web Server
Pros:
Implementation:
Option 3: Reverse Proxy (Workaround)
Pros:
Cons:
Documentation approach:
Create
TLS_DEPLOYMENT.mdwith nginx configuration:Recommended Approach
Phase 1 (Short-term): Document reverse proxy setup in
TLS_DEPLOYMENT.mdPhase 2 (Medium-term): Complete
jplatform-rest-api-nettymodule with TLSConfiguration Design
Add TLS settings to
ApiServerConfig:Acceptance Criteria
Phase 1 (Documentation):
TLS_DEPLOYMENT.mdcreated with reverse proxy examplesPhase 2 (Netty Implementation):
jplatform-rest-api-nettymodule completedApiServerConfigVerification Steps
Phase 1:
curl https://localhost:443/api/applicationsopenssl s_client -connect localhost:443 -tls1_2Phase 2:
keytool -genkeypair ...mvn exec:java -pl jplatform-launchercurl -k https://localhost:8443/api/applicationsnmap --script ssl-enum-ciphers -p 8443 localhostReferences
Priority: HIGH | Production Readiness Review Score: 8.3/10