springboot2 配置 https

1package cn.xiaojf.aibus.configure; 2 3import org.apache.catalina.Context; 4import org.apache.catalina.connector.Connector; 5import org.apache.coyote.http11.Http11NioProtocol; 6import org.apache.tomcat.util.descriptor.web.SecurityCollection; 7import org.apache.tomcat.util.descriptor.web.SecurityConstraint; 8import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; 9import org.springframework.boot.web.servlet.server.ServletWebServerFactory; 10import org.springframework.context.annotation.Bean; 11import org.springframework.context.annotation.Configuration; 12import org.springframework.context.annotation.Profile; 13 14/** 15 * http ssl 配置 16 * @author xiaojf 2019/9/21 20:07 17 */ 18@Configuration 19@Profile("prod") 20public class HttpsConfigure { 21 22 @Bean 23 public ServletWebServerFactory servletWebServerFactory() { 24 TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() { 25 @Override 26 protected void postProcessContext(Context context) { 27 SecurityConstraint securityConstraint = new SecurityConstraint(); 28 securityConstraint.setUserConstraint("CONFIDENTIAL"); 29 SecurityCollection securityCollection = new SecurityCollection(); 30 securityCollection.addPattern("/*"); 31 securityConstraint.addCollection(securityCollection); 32 context.addConstraint(securityConstraint); 33 } 34 }; 35 factory.addAdditionalTomcatConnectors(redirectConnector()); 36 return factory; 37 } 38 39 private Connector redirectConnector() { 40 Connector connector = new Connector(Http11NioProtocol.class.getName()); 41 connector.setScheme("http"); 42 connector.setPort(8100); 43 connector.setSecure(false); 44 connector.setRedirectPort(443); 45 return connector; 46 } 47}

  修改配置文件

1server: 2 ssl: 3 key-store: classpath:ssl/2833975_www.renyimao.cn.pfx 4 key-store-password: KzwpacCY 5 keyStoreType: PKCS12 6 port: 443 #启动端口

  文件目录

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang

KVM调整cpu和内存

一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid