Skip to content

Commit

Permalink
添加https支持
Browse files Browse the repository at this point in the history
  • Loading branch information
zhh committed Aug 6, 2018
1 parent 575eb0a commit 69ec434
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Binary file added keystore.p12
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
package com.macro.mall.portal;

import org.apache.catalina.connector.Connector;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan({"com.macro.mall.mapper","com.macro.mall.portal.dao"})
public class MallPortalApplication {
@Value("${http.port}")
private Integer port;

public static void main(String[] args) {
SpringApplication.run(MallPortalApplication.class, args);
}

@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
return tomcat;
}

//配置http
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
return connector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ protected void configure(HttpSecurity http) throws Exception {
.logoutSuccessHandler(new GoLogoutSuccessHandler())
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID")
// .and()
// .requiresChannel()
// .antMatchers("/sso/*").requiresSecure()
// .anyRequest().requiresInsecure()
.and()
.requiresChannel()
.antMatchers("/sso/*")
.requiresSecure()
.anyRequest()
.requiresInsecure()
// .and()
// .rememberMe()
// .tokenValiditySeconds(1800)
Expand Down
7 changes: 6 additions & 1 deletion mall-portal/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#===server start===
server.port=8085
http.port=8085
server.port=8443
server.ssl.key-store=keystore.p12
server.ssl.key-alias=tomcat
server.ssl.key-store-password=123456
server.ssl.key-store-type=PKCS12
#===server end===

#===logging start===
Expand Down

0 comments on commit 69ec434

Please sign in to comment.