首页 > 其他分享 >怎么在springboot中配置https证书的详细教程

怎么在springboot中配置https证书的详细教程

时间:2023-04-03 20:46:18浏览次数:36  
标签:Connector 教程 springboot 二级域名 connector 域名 https

前言

由于小程序需要https,然后之前申请的域名过期了,用了两年由于忘记续费要将域名赎回居然要1200....
想了一下之前还有另一个域名,干脆就用这个域名弄个二级域名出来,所以二级域名建立出来后需要在springboot项目上开启https访问
废话不多说,开整

在阿里云新建二级域名

这个应该不用说

下载ssl证书

jks证书

springboot的yml配置文件


server:
  port: 80
  servlet:
    context-path: /xx
  ssl:
    key-store: classpath:xx.jks
    key-store-password: 密码
    keyStoreType: JKS
    enabled: true

启动文件配置以下信息

    @Bean
    public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
        tomcat.addAdditionalTomcatConnectors(createHTTPConnector());
        return tomcat;
    }
    private Connector createHTTPConnector() {
        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        //同时启用http(8080)、https(8099)两个端口
        connector.setScheme("http");
        connector.setSecure(false);
        connector.setPort(8080);
        connector.setRedirectPort(8099);
        return connector;
    }

启动本地项目

本地成功访问

服务器启动访问

成功访问

标签:Connector,教程,springboot,二级域名,connector,域名,https
From: https://www.cnblogs.com/rzkwz/p/17284336.html

相关文章

  • SpringBoot启动异常的错误①
    java:无法访问org.springframework.boot.SpringApplication错误的类文件:/D:/maven/repository/org/springframework/boot/spring-boot/3.0.5/spring-boot-3.0.5.jar!/org/springframework/boot/SpringApplication.class类文件具有错误的版本61.0,应为52.0 2023-04......
  • 网站https加密
    Whenaclient(e.g.,awebbrowser)establishesasecureHTTPSconnectionwithaserver,thefollowingstepsoccurtoensurethesecurityofthecommunication:TheclientinitiatestheHTTPSconnectionbyrequestingasecureresourcefromtheserver,ty......
  • windows安装npm教程(nodejs)
     1、在使用之前,先类掌握3个东西,明白它们是用来干什么的:npm: nodejs下的包管理器。webpack:它主要用途是通过CommonJS的语法把所有浏览器端需要发布的静态资源作相应的准备,比如资源的合并和打包。vue-cli:用户生成Vue工程模板。(帮你快速开始一个vue的项目,也就是给你一......
  • springboot 日志
    <loggername="com.sinoservices.chainwork.bms"level="INFO"/><loggername="org.hibernate.orm.deprecation"level="error"/><loggername="druid"additivity="true"><levelval......
  • 下载Maven教程
    前言:Maven是学习Spring的捷径,可以帮助项目快速发布;是apache的一个开源项目,并且具有跨平台的特性(同一套指令适用于不同系统),主要提高基于java平台的项目构建、依赖管理、项目信息管理等服务;可以看作一个统一管理jar包的开发规范和工具。【maven的下载必须是建立在已有jdk的前提......
  • 如何使用HTTPS加密保护网站?
    加密Web内容并不是什么新鲜事:自发布通过SSL/TLS协议来加密Web内容的规范以来,已经过去了近20年。然而,近年来,运行安全的HTTPS加密Web服务器已经从一种选择变成了一种安全防护的必需品。攻击者继续寻找并找到窃取用户和Web服务之间发送的信息的方法,通常是通过利用通过超文本......
  • 26-springboot-thymeleaf字符串拼接-常量-符号
    Thymeleaf字符串拼接一种是字符串拼接:<spanth:text="'当前是第'+${sex}+'页,共'+${sex}+'页'"></span>另一种更简洁的方式,使用“|”减少了字符串的拼接:<spanth:text="|当前是第${sex}页,共${sex}页|"></span>Thymeleaf可直接使用的常量和符号1、所有......
  • 27-springboot-thymeleaf内置对象
    1、内置web对象thymaleaf内置的web对象,可以直接在模板中使用,这些对象由#号开头:#request:相当于HttpServletRequest对象,这是Thymeleaf3.x版本,若是Thymeleaf2.x版本使用#httpServletRequest;${#request.getContextPath()}${#request.getAttribute("phone")}#session:相当于H......
  • 24-springboot-thymeleaf的表达式
    1.添加热部署,为了测试不用频繁重启<!--热部署插件--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional><!--防止将该依赖传递到其他模块中--></depen......
  • 25-springboot-thymeleaf的常见属性
    th:action<formid="login"th:action="@{/login}">......</form>th:method<formid="login"th:action="@{/login}"th:method="post">......</form>th:href<a class="login"......