Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2569c2eba | |||
| 670b15774c | |||
| 5c8a96034c | |||
| 49fc2dbff2 | |||
| 08e6fca59d | |||
| 03faa454a6 | |||
| 7bf4c268ce | |||
| e2207ad688 | |||
| 257f3b1baf | |||
| 0580907b37 |
7
template/.gitignore
vendored
7
template/.gitignore
vendored
@@ -33,10 +33,3 @@ logs/
|
||||
!modules/.gitkeep
|
||||
.gitattributes
|
||||
.toco/config.local.yml
|
||||
.fslckout
|
||||
_FOSSIL_
|
||||
_FOSSIL_-journal
|
||||
.fslckout
|
||||
.fslckout-journal
|
||||
|
||||
*.pem
|
||||
@@ -63,11 +63,6 @@
|
||||
<artifactId>rocketmq-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package {{ .package }}.entrance.web.config;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Configuration
|
||||
public class SSLConfig {
|
||||
|
||||
@Bean
|
||||
public ServletWebServerFactory servletContainer(Environment env) {
|
||||
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
|
||||
|
||||
// 禁用自动配置的SSL(如果存在)
|
||||
tomcat.setRegisterDefaultServlet(false);
|
||||
|
||||
if (hasSslConfig(env)) {
|
||||
tomcat.addAdditionalTomcatConnectors(createSslConnector(env));
|
||||
}
|
||||
|
||||
return tomcat;
|
||||
}
|
||||
|
||||
private boolean hasSslConfig(Environment env) {
|
||||
return env.containsProperty("ssl_certificate")
|
||||
&& env.containsProperty("ssl_certificate-private-key");
|
||||
}
|
||||
|
||||
private Connector createSslConnector(Environment env) {
|
||||
String certPath = env.getProperty("ssl_certificate");
|
||||
String keyPath = env.getProperty("ssl_certificate-private-key");
|
||||
String httpsPort = env.getProperty("server.https.port", "8443");
|
||||
|
||||
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
||||
connector.setScheme("https");
|
||||
connector.setSecure(true);
|
||||
connector.setPort(Integer.parseInt(httpsPort));
|
||||
|
||||
// 明确设置SSL配置
|
||||
connector.setProperty("SSLEnabled", "true");
|
||||
connector.setProperty("sslProtocol", "TLS");
|
||||
connector.setProperty("clientAuth", "false");
|
||||
connector.setProperty("sslEnabledProtocols", "TLSv1.2,TLSv1.3");
|
||||
|
||||
// 处理证书路径
|
||||
connector.setProperty("certificateFile", extractFilePath(certPath));
|
||||
connector.setProperty("certificateKeyFile", extractFilePath(keyPath));
|
||||
|
||||
return connector;
|
||||
}
|
||||
|
||||
private String extractFilePath(String classpathResource) {
|
||||
if (classpathResource == null) return null;
|
||||
|
||||
if (classpathResource.startsWith("classpath:")) {
|
||||
String resource = classpathResource.substring("classpath:".length());
|
||||
try {
|
||||
return new ClassPathResource(resource).getFile().getAbsolutePath();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to locate SSL certificate file", e);
|
||||
}
|
||||
}
|
||||
return classpathResource;
|
||||
}
|
||||
}
|
||||
@@ -128,4 +128,3 @@ liteflow.monitor.enable-log=true
|
||||
#create default table auto
|
||||
vs.db.basetable.create=true
|
||||
|
||||
server.ssl.enabled=false
|
||||
|
||||
@@ -80,7 +80,6 @@
|
||||
<ox.sprintboot.web.starter.version>1.0-SNAPSHOT</ox.sprintboot.web.starter.version>
|
||||
<ox.basidc.common>1.0-SNAPSHOT</ox.basidc.common>
|
||||
<vs.sqlmapper.spring>1.0.0-SNAPSHOT</vs.sqlmapper.spring>
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
{{- if eq .dbType "dm" }}
|
||||
<dm.driver.version>18</dm.driver.version>
|
||||
<db.hiernate.dialect.version>8.1.3.140</db.hiernate.dialect.version>
|
||||
@@ -372,11 +371,6 @@
|
||||
<artifactId>opensearch-rest-high-level-client</artifactId>
|
||||
<version>${opensearch.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
@@ -474,6 +468,23 @@
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>2.43.0</version>
|
||||
<configuration>
|
||||
<java>
|
||||
<googleJavaFormat>
|
||||
<groupArtifact>com.google.googlejavaformat:google-java-format</groupArtifact>
|
||||
<version>1.22.0</version>
|
||||
<style>AOSP</style>
|
||||
<reorderImports>true</reorderImports>
|
||||
<reflowLongStrings>true</reflowLongStrings>
|
||||
<formatJavadoc>true</formatJavadoc>
|
||||
</googleJavaFormat>
|
||||
</java>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<modules>
|
||||
|
||||
Reference in New Issue
Block a user