【问题标题】:How to run a fully FIPS compliant Spring Boot application如何运行完全符合 FIPS 的 Spring Boot 应用程序
【发布时间】:2019-12-02 16:02:38
【问题描述】:

我必须满足以下条件:

  • Tomcat 在 FIPS 模式下运行
  • JDK 使用 FIPS ssl Provider

这将使应用程序“以 FIPS 模式运行”。这个假设正确吗?

我认为Tomcat is configured using an APR Lifecycle Listener,APR 需要certain native components to be installed。在这些组件可用后,可以使用this 启用APR(考虑this)。对吗?

自我说明:Not everybody thinks of APR to be a good idea

现在 FIPS SSL Provider seems to be related to SunJSSE,似乎是 there are JAR files providing functionality for this。它是否正确?尽管这些 JAR 不是原生的,但这些 JAR 是否也足以用于 Tomcat?

这些问题很多,我知道。但基本上是如何运行完全符合 FIPS 的 Spring Boot 应用程序

【问题讨论】:

    标签: spring-boot tomcat fips


    【解决方案1】:

    第 1 部分:“Tomcat 在 FIPS 模式下运行”,在 Ubuntu 上

    前言 #1:可以在here 找到一些通用(但不完整)说明。

    前言 #2:以下要求 OpenSSL 和 FIPS 140-2 认证模块。在 Ubuntu 上,这些仅适用于 Ubuntu 16.04 上的“Ubuntu Advantage Advanced 客户”!请参阅herehere

    • $ sudo apt install libapr1 libapr1-dev (来自here,可能是sudo apt install libapr1-dev libssl-dev,请参阅here
    • here下载tomcat-native-1.2.23-src,解压,转到tomcat-native-1.2.23-src/native/
    • $ ./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/path/to/java-home/ --with-ssl=yes
    • $ make
    • -Djava.library.path=/path/to/tomcat-native-1.2.23-src/native/.libs 添加到jvm args
    • 将以下内容添加到您的项目中
    import org.apache.catalina.core.AprLifecycleListener;
    import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
    import org.springframework.boot.web.server.Ssl;
    import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    @Configuration
    public class AprConfig {
    
      @Bean
      public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() {
          @Override
          public Ssl getSsl() {
            // avoid "IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass":
            return null;
          }
        };
    
        // enable APR:
        factory.setProtocol("org.apache.coyote.http11.Http11AprProtocol");
    
        AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
    
        // will throw "FIPS was not available to tcnative at build time. You will need to re-build tcnative against an OpenSSL with FIPS." with default OpenSSL:
        aprLifecycleListener.setFIPSMode("on");
    
        factory.addContextLifecycleListeners(aprLifecycleListener);
        return factory;
      }
    }
    

    第 2 部分:“JDK 使用 FIPS ssl 提供程序”

    Java 使用 JCE "to use stronger versions of standard algorithms"。需要为最高 8u161、7u171 和 6u16 的 JDK 安装相应的策略文件; “在这些版本及更高版本中,策略文件已包含在内,但默认情况下未启用”,而“JDK 9 及更高版本附带并默认使用无限策略文件”。

    JCE 是一个由一些“提供者”实现的接口(就像 JDBC 是一个必须实现的接口)。尽管 Oracle 甚至有一个实现,但符合 FIPS 的提供者并不多(请参阅this list)。我发现只有一个声称与 Java 11 兼容,即版本 1.0.2 中的 "Bouncy Castle Crypto API" - 目前“可用于早期访问”,请参阅 Java FIPS Roadmap。所以这里也要考虑 Java 版本 (see)。

    结论

    运行完全符合 FIPS 的 Spring Boot 应用程序需要

    • 一些配置(见上文)
    • 具有 FIPS 兼容库的操作系统支持您的 Java 版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-18
      • 2017-06-22
      • 2016-04-15
      • 2021-06-09
      • 2023-03-16
      • 2018-08-08
      • 2020-10-26
      • 2020-10-03
      相关资源
      最近更新 更多