package cn.xiaojf.aibus.configure;

import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
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.context.annotation.Profile; /**
* http ssl 配置
* @author xiaojf 2019/9/21 20:07
*/
@Configuration
@Profile("prod")
public class HttpsConfigure { @Bean
public ServletWebServerFactory servletWebServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection securityCollection = new SecurityCollection();
securityCollection.addPattern("/*");
securityConstraint.addCollection(securityCollection);
context.addConstraint(securityConstraint);
}
};
factory.addAdditionalTomcatConnectors(redirectConnector());
return factory;
} private Connector redirectConnector() {
Connector connector = new Connector(Http11NioProtocol.class.getName());
connector.setScheme("http");
connector.setPort(8100);
connector.setSecure(false);
connector.setRedirectPort(443);
return connector;
}
}

  修改配置文件

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

  文件目录

springboot2 配置 https的更多相关文章

  1. 腾讯云域名申请+ssl证书申请+springboot配置https

    阿里云域名申请 域名申请比较简单,使用微信注册阿里云账号并登陆,点击产品,选择域名注册 输入你想注册的域名 进入域名购买页面,搜索可用的后缀及价格,越热门的后缀(.com,.cn)越贵一般,并且很可能 ...

  2. SpringBoot配置Https

    HTTPS (全称:Hyper Text Transfer Protocol over SecureSocket Layer),是以安全为目标的 HTTP 通道,在HTTP的基础上通过传输加密和身份认 ...

  3. Nginx配置Https

    1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ...

  4. 天河微信小程序入门:阿里云tomcat免费配置https

    天河君在第一时间通过了微信小程序验证,开启了我的微信小程序之旅.因为天河君之前是一名后端狗,对前端不是很了解,所以几乎可以认为是从零开始学做微信小程序.也希望有志在微信小程序方向做点事情的朋友能够和我 ...

  5. 在 IIS 6 和 IIS 7中配置Https,设置WCF同时支持HTTP和HTPPS,以及使用HttpWebRequest和HttpClient调用HttpS

    IIS 7 ,给IIS添加CA证书以支持https IIS 6 架设证书服务器 及 让IIS启用HTTPS服务 WCF IIS 7中配置HTTPS C#利用HttpWebRequest进行post请求 ...

  6. nginx 反向代理 配置 https 实现http https同时存在

    server { listen ssl; #监听443端口 server_name www.app01.com; ssl on; #启用ssl加密 ssl_certificate /etc/cert/ ...

  7. 【burp】配置HTTPS抓包方法

    以Chrome为例,配置HTTPS抓包方法 1.获取破解版的burp,将BurpLoader.jar和burpsuite_pro_v1.5.18.jar放到一个路径下 2.在cmd里进入上述两个jar ...

  8. YTKNetworkConfig配置HTTPS请求

    YTKNetworkConfig配置HTTPS请求 p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ad91cc ...

  9. Apache配置HTTPS功能

    apache配置https 一.yum 安装openssl和openssl-devel,httpd-devel 二.生成证书(也可以从公司的证书颁发机构获取): #建立服务器密钥 openssl ge ...

随机推荐

  1. python开发笔记-如何做数据准备

    时间格式: >>> from datetime import date >>> firstday = date.fromtimestamp(1464010200) ...

  2. java中异步调用注意

    Future接口是Java标准API的一部分,在java.util.concurrent包中.Future接口是Java线程Future模式的实现,可以来进行异步计算. 有了Future就可以进行三段 ...

  3. npm包之npm-check-updates

    检查npm的依赖包是否有比较新的版本 安装 npm i -g npm-check-updates 使用 ncu --help // 查看相关命令 ncu // 检查当前项目中有没有哪些依赖包可更新 n ...

  4. janusgraph单机版安装

    注:本次安装janusgraph基于es和hbse,所以先安装es和hbase 1.安装jdk 2.安装janusgraph 解压安装文件至/usr/janusgraph-0.3.1 unzip ja ...

  5. python的整数相除

    在python2中: 10/4=2 在python3中: 10/4=2.5 10//4=2

  6. 输入一个正整数n,生成一张2的乘方表,输出2*0—2*n的值。

    #include<stdio.h>#include<math.h> //程序中调用幂函数pow(),需包含头文件math.h//void main(){ int i,n; pr ...

  7. CSPS_109

    T1 状压+位运算解决 T2 打完暴力后感到了迷茫.. 不过看这张表里1的数目占了一半之多,应该合法情况挺多的 拿出了从未用过的srand(time(0)); 结果撞上正解了(笑)(rp--) 现在$ ...

  8. 洛谷 P2858 [USACO06FEB]奶牛零食Treats for the Cows 题解

    P2858 [USACO06FEB]奶牛零食Treats for the Cows 题目描述 FJ has purchased N (1 <= N <= 2000) yummy treat ...

  9. 自助法(Bootstraping)

    自助法(Bootstraping)是另一种模型验证(评估)的方法(之前已经介绍过单次验证和交叉验证:验证和交叉验证(Validation & Cross Validation)).其以自助采样 ...

  10. mysql sqrt() 函数

    mysql> ); +----------+ | sqrt() | +----------+ | | +----------+ row in set (0.00 sec)