Skip to content

Commit 674a08a

Browse files
authored
Merge pull request #665 from Kaliumhexacyanoferrat/spring-boot-json-lts
[Java] Spring Boot: Enable JSON TLS
2 parents ae7b5d2 + 8a32ff9 commit 674a08a

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

frameworks/spring-boot/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"pipelined",
1313
"json",
1414
"json-comp",
15+
"json-tls",
1516
"upload",
1617
"static",
1718
"async-db",

frameworks/spring-boot/src/main/java/com/httparena/spring/boot/Application.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.zaxxer.hikari.HikariConfig;
44
import com.zaxxer.hikari.HikariDataSource;
55
import org.apache.catalina.connector.Connector;
6+
import org.apache.tomcat.util.net.SSLHostConfig;
7+
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
68
import org.postgresql.ds.PGSimpleDataSource;
79
import org.springframework.beans.factory.annotation.Qualifier;
810
import org.springframework.boot.SpringApplication;
@@ -21,6 +23,7 @@
2123
import org.sqlite.SQLiteDataSource;
2224

2325
import javax.sql.DataSource;
26+
import java.io.File;
2427
import java.net.URI;
2528
import java.net.URISyntaxException;
2629

@@ -92,10 +95,31 @@ public void customize(final TomcatServletWebServerFactory factory) {
9295
connector.setPort(8080);
9396
connectorCustomizer.customize(connector);
9497
factory.addAdditionalConnectors(connector);
98+
99+
String certPath = System.getenv().getOrDefault("TLS_CERT", "/certs/server.crt");
100+
String keyPath = System.getenv().getOrDefault("TLS_KEY", "/certs/server.key");
101+
102+
if (new File(certPath).exists() && new File(keyPath).exists()) {
103+
Connector tlsConnector = new Connector("HTTP/1.1");
104+
tlsConnector.setPort(8081);
105+
tlsConnector.setScheme("https");
106+
tlsConnector.setSecure(true);
107+
tlsConnector.setProperty("SSLEnabled", "true");
108+
109+
SSLHostConfig sslHostConfig = new SSLHostConfig();
110+
SSLHostConfigCertificate certificate = new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.UNDEFINED);
111+
certificate.setCertificateFile(certPath);
112+
certificate.setCertificateKeyFile(keyPath);
113+
sslHostConfig.addCertificate(certificate);
114+
tlsConnector.addSslHostConfig(sslHostConfig);
115+
116+
factory.addAdditionalConnectors(tlsConnector);
117+
}
95118
}
96119

97120
@Override
98121
public void registerWebSocketHandlers(final WebSocketHandlerRegistry registry) {
99122
registry.addHandler(new EchoWebSocketHandler(), "/ws");
100123
}
124+
101125
}

site/data/json-tls-4096.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,25 @@
383383
"status_4xx": 0,
384384
"status_5xx": 0
385385
},
386+
{
387+
"framework": "spring-boot",
388+
"language": "Java",
389+
"rps": 188030,
390+
"avg_latency": "20.64ms",
391+
"p99_latency": "20.64ms",
392+
"cpu": "2659.2%",
393+
"memory": "3.2GiB",
394+
"connections": 4096,
395+
"threads": 64,
396+
"duration": "5s",
397+
"pipeline": 1,
398+
"bandwidth": "651.02MB",
399+
"reconnects": 0,
400+
"status_2xx": 958731,
401+
"status_3xx": 0,
402+
"status_4xx": 0,
403+
"status_5xx": 0
404+
},
386405
{
387406
"framework": "Swoole",
388407
"language": "PHP",
@@ -440,4 +459,4 @@
440459
"status_4xx": 0,
441460
"status_5xx": 0
442461
}
443-
]
462+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
. ____ _ __ _ _
3+
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
4+
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
5+
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
6+
' |____| .__|_| |_|_| |_\__, | / / / /
7+
=========|_|==============|___/=/_/_/_/
8+
9+
:: Spring Boot :: (v4.0.5)
10+
11+
2026-04-27T18:31:28.780Z INFO 1 --- [spring-boot] [ main] com.httparena.spring.boot.Application : Starting Application v0.0.1-SNAPSHOT using Java 25.0.2 with PID 1 (/app/app.jar started by root in /app)
12+
2026-04-27T18:31:28.783Z INFO 1 --- [spring-boot] [ main] com.httparena.spring.boot.Application : No active profile set, falling back to 1 default profile: "default"
13+
2026-04-27T18:31:29.727Z INFO 1 --- [spring-boot] [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat initialized with ports 8443 (https), 8080 (http), 8081 (https)
14+
2026-04-27T18:31:29.742Z INFO 1 --- [spring-boot] [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
15+
2026-04-27T18:31:29.742Z INFO 1 --- [spring-boot] [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/11.0.20]
16+
2026-04-27T18:31:29.762Z INFO 1 --- [spring-boot] [ main] b.w.c.s.WebApplicationContextInitializer : Root WebApplicationContext: initialization completed in 917 ms
17+
2026-04-27T18:31:30.341Z INFO 1 --- [spring-boot] [ main] o.a.t.util.net.NioEndpoint.certificate : Connector [https-jsse-nio-8443], TLS virtual host [_default_], certificate type [UNDEFINED] configured from keystore [Set directly - location unknown] using alias [tomcat] with trust store [null]
18+
2026-04-27T18:31:30.356Z INFO 1 --- [spring-boot] [ main] o.a.t.util.net.NioEndpoint.certificate : Connector [https-jsse-nio-8081], TLS virtual host [_default_], certificate type [UNDEFINED] configured from key [/certs/server.key], certificate [/certs/server.crt] and certificate chain [null] with trust store [null]
19+
2026-04-27T18:31:30.360Z INFO 1 --- [spring-boot] [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat started on ports 8443 (https), 8080 (http), 8081 (https) with context path '/'
20+
2026-04-27T18:31:30.373Z INFO 1 --- [spring-boot] [ main] com.httparena.spring.boot.Application : Started Application in 1.965 seconds (process running for 2.487)
21+
2026-04-27T18:31:31.001Z INFO 1 --- [spring-boot] [nio-8081-exec-5] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
22+
2026-04-27T18:31:31.001Z INFO 1 --- [spring-boot] [nio-8081-exec-5] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
23+
2026-04-27T18:31:31.002Z INFO 1 --- [spring-boot] [nio-8081-exec-5] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms

0 commit comments

Comments
 (0)