【问题标题】:Spring Boot - Creating HTTPS-connection does not workSpring Boot - 创建 HTTPS 连接不起作用
【发布时间】:2017-01-29 10:34:17
【问题描述】:

我正在使用 Spring Boot Framework 开发一个带有 embedded Tomcat 的 Web 应用程序。需要为多个端口建立一些 https 连接。

为此,我使用了 SpringApplicationBuilder,如下所示:

SpringApplicationBuilder parentBuilder
            = new SpringApplicationBuilder(ApplicationConfiguration.class);

    parentBuilder.child(WithoutClientAuth.class)
            .properties("server.port:8443")
            .properties("security.require_ssl=true")
            .properties("ssl.key-store=server.jks")
            .properties("ssl.key-store-password=password")
            .properties("ssl.key-password=password")
            .run(args);

    parentBuilder.child(WithClientAuth.class)
            .properties("server.port:9443")
            .properties("security.require_ssl=true")
            .properties("ssl.key-store=server.jks")
            .properties("ssl.key-store-password=password")
            .properties("ssl.key-password=password")
            .run(args);

但是,启动应用程序后,通信协议不安全。可以在输出中看到:

TomcatEmbeddedServletContainer : Tomcat initialized with port(s):  9443 (http)
StandardService                : Starting service Tomcat
StandardEngine                 : Starting Servlet Engine: Apache Tomcat/8.5.4

您有想法以这种方式进行安全通信吗?

【问题讨论】:

    标签: java web-applications https spring-boot


    【解决方案1】:

    您用于 SSL 配置的属性有误。它们都应该以server.为前缀:

    parentBuilder.child(WithoutClientAuth.class)
            .properties("server.port:8443")
            .properties("security.require_ssl=true")
            .properties("server.ssl.key-store=server.jks")
            .properties("server.ssl.key-store-password=password")
            .properties("server.ssl.key-password=password")
            .run(args);
    

    【讨论】:

      猜你喜欢
      • 2014-08-16
      • 2019-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      • 2018-12-08
      • 2020-11-30
      相关资源
      最近更新 更多