可以配置  Jtest 以符合 FIPS 的要求。

章节目录:

前提条件

需在 https://www.bouncycastle.org/download/bouncy-castle-java-fips/ 下载以下 BouncyCastle FIPS 库:

  • bc-fips-<VERSION>.jar(已使用 1.0.2.5 版本测试)
  • bctls-fips-<VERSION>.jar(已使用 1.0.19 版本测试)

在 Jtest 中配置 FIPS 模式

  1. 将 bc-fips-<VERSION>.jar 和 bctls-fips-<VERSION>.jar 复制到  <JTEST_INSTALL_DIR>/bin 目录。

  2. 使用 keytool 将 cacerts 文件转换为符合 FIPS 要求的 BCFKS 格式。
    1. 打开控制台并执行以下命令:

      cd <JTEST_INSTALL_DIR>
      
      mv bin/jre/lib/security/cacerts bin/jre/lib/security/cacerts.jks
      
      ./bin/jre/bin/keytool -importkeystore -srckeystore bin/jre/lib/security/cacerts.jks -srcstoretype JKS -destkeystore bin/jre/lib/security/cacerts -deststoretype BCFKS -providername BCFIPS -providerclass org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider -providerpath bin/bc-fips-<VERSION>.jar -srcstorepass changeit -deststorepass changeit


    2. 打开 <JTEST_INSTALL_DIR>/etc 目录中的 jtestcli.jvm 文件,并插入下列一行内容:

      java.arg=-Djavax.net.ssl.trustStorePassword=changeit

  3. 保存变更。
  4. 打开  <JTEST_INSTALL_DIR>/bin/jre/conf/security/ 目录中的 java.security 文件,完成以下更改: 

    1. 注释掉已有的所有名为 security.provider.<number>. 的属性,然后插入下列几行内容来设置安全提供者列表:

      security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider
      security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS
      security.provider.3=SUN
    2. 将 javax.net.ssl 包的密钥和信任管理器工厂算法更改为 PKIX。

      ssl.KeyManagerFactory.algorithm=PKIX
      ssl.TrustManagerFactory.algorithm=PKIX
    3. 将默认密钥库类型更改为 fips,并禁用 JKS 和 PKCS12 密钥库类型的兼容模式。

      keystore.type=fips
      keystore.type.compat=false
    4. (仅限 Linux)在已知强 SecureRandom 实现列表中添加 NativePRNGNonBlocking 算法:

      securerandom.strongAlgorithms=NativePRNGNonBlocking:SUN,NativePRNGBlocking:SUN,DRBG:SUN
    5. 仅允许 FIPS 批准的算法:

      org.bouncycastle.fips.approved_only=true
  5. 保存变更。
  6. 打开  <JTEST_INSTALL_DIR>/bin/jre/conf/security/ 目录中的 java.policy 文件,将以下权限插入到默认域中:

    permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec";
    permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled";
  7. 保存变更。
  8. 打开  <JTEST_INSTALL_DIR>/bin/jre/conf/ 目录中的 logging.properties 文件,插入以下 Bouncy Castle 日志记录器配置:

    org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints.level=SEVERE
    org.bouncycastle.jsse.provider.PropertyUtils.level=SEVERE
    org.bouncycastle.jsse.provider.ProvTlsClient.level=SEVERE
  9. 保存变更。


  • No labels