Пустое свойство безопасности securerandom.strongAlgorithms - PullRequest
0 голосов
/ 19 октября 2018

Когда я настраиваюсь как приложение в Jenkins.Код прекрасно работает в локальной и других средах сборки.В Jenkins я получаю эту ошибку во время сборки и модульных тестов.Наше приложение требует только внешних изменений: загрузите JCE (расширение Jave Crypto) из oracle и замените jar-файлы политики в папке JAVA_HOME / jre / lib / security.что я и сделал.Я вижу журнал, он собирает эти банки.Тем не менее я вижу ниже ошибку.Нужно ли что-нибудь сделать для безопасного случайного?SecureRandom.getInstanceStrong(); вызывает проблему.любая помощь?

[ERROR] Null/empty securerandom.strongAlgorithms Security Property
[ERROR]     at com.test.cipher.AesGcmCipher.generate(AesGcmCipher.java:72)
[ERROR]     at com.test.scheme.Version1CryptoSchemeAesGcmTest$1.getDefaultCipher(Version1CryptoSchemeAesGcmTest.java:27)
[ERROR]     at com.test.scheme.Version1CryptoSchemeAesGcmTest$1.getDefaultCipher(Version1CryptoSchemeAesGcmTest.java:24)
[ERROR]     at com.test.CachingCryptoCipherProvider.<init>(CachingCryptoCipherProvider.java:43)
[ERROR]     at com.test.CryptoCipherProvider.asCachingProvider(CryptoCipherProvider.java:28)
[ERROR]     at com.test.scheme.Version1CryptoSchemeAesGcmTest.createAesGcmProvider(Version1CryptoSchemeAesGcmTest.java:35)
[ERROR]     at com.test.scheme.Version1CryptoSchemeAesGcmTest.<init>(Version1CryptoSchemeAesGcmTest.java:20)
[ERROR]     ... 28 more
[ERROR] Caused by: java.security.NoSuchAlgorithmException: Null/empty securerandom.strongAlgorithms Security Property
[ERROR]     at java.security.SecureRandom.getInstanceStrong(SecureRandom.java:627)
[ERROR]     at com.test.cipher.AesGcmCipher.generate(AesGcmCipher.java:62)
[ERROR]     ... 34 more`

Ниже мой код Java.

public class AesGcmCipher {
    public static AesGcmCipher generate(BiConsumer<AesGcmCipher, SecretKey> consumer) {
        try {
            UUID cipherId = UUID.randomUUID();
            SecureRandom random = SecureRandom.getInstanceStrong();
            KeyGenerator keyGen = KeyGenerator.getInstance(AES);
            AesGcmCipher cipher = new AesGcmCipher(cipherId, secretKey, new Date());
            return cipher;
        } catch (NoSuchAlgorithmException ex) {
            LOGGER.error(msg);
            throw new CryptoException(msg, ex);
        }
    }
}

К вашему сведению, Дженкинс работает на java version "1.8.0_73".Код, который отлично работает на других машинах с версиями 1.8.0_51 и 1.8.0_91

1 Ответ

0 голосов
/ 19 октября 2018

Это должно быть проблемой с вашим JDK.Не могли бы вы проверить этот файл $JAVA_HOME/jre/lib/security/java.security:

securerandom.source=file:/dev/random
securerandom.strongAlgorithms=NativePRNGBlocking:SUN

Это моя конфигурация, возможно, вам потребуется переустановить JDK

...