Невозможно расшифровать: ключ = admin.password (свойство Spring), ошибка только в настройке затмения - PullRequest
0 голосов
/ 02 декабря 2018

У меня есть git-репозиторий весеннего загрузочного кода, в котором 2 свойства зашифрованы в application.properties, когда я использую ключ дешифрования в файле оболочки / CMD, как этот

@ECHO OFF
SET ENCRYPT_KEY=******

java -jar ./target/*****AppName-1.0.jar

Jar работаетбез проблем, но когда я использую тот же ключ в переменных среды в eclipse и пытаюсь запустить приложение в eclipse - это дает мне эту ошибку

SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
2018-12-02 19:55:18.615  INFO 6820 --- [JavaFX-Launcher] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@790175: startup date [Sun Dec 02 19:55:18 IST 2018]; root of context hierarchy
2018-12-02 19:55:19.313  INFO 6820 --- [JavaFX-Launcher] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-12-02 19:55:19.474  INFO 6820 --- [JavaFX-Launcher] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$b7666f03] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.2.RELEASE)

2018-12-02 19:55:20.974  WARN 6820 --- [JavaFX-Launcher] o.s.boot.SpringApplication               : Error handling failed (ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1067f29: startup date [Thu Jan 01 05:30:00 IST 1970]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@790175)
2018-12-02 19:55:20.993 ERROR 6820 --- [JavaFX-Launcher] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalStateException: Cannot decrypt: key=admin.password
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:201) ~[spring-cloud-context-1.2.2.RELEASE.jar:1.2.2.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:165) ~[spring-cloud-context-1.2.2.RELEASE.jar:1.2.2.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:95) ~[spring-cloud-context-1.2.2.RELEASE.jar:1.2.2.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer.initialize(BootstrapApplicationListener.java:370) ~[spring-cloud-context-1.2.2.RELEASE.jar:1.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:611) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:348) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at com.****AppName.Main.springBootApplicationContext(Main.java:61) [classes/:na]
    at com.****AppName.Main.init(Main.java:38) [classes/:na]
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841) [jfxrt.jar:na]
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) [jfxrt.jar:na]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_141]
Caused by: java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key
    at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:120) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.crypto.encrypt.AesBytesEncryptor.decrypt(AesBytesEncryptor.java:126) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.decrypt(HexEncodingTextEncryptor.java:40) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:193) ~[spring-cloud-context-1.2.2.RELEASE.jar:1.2.2.RELEASE]
    ... 12 common frames omitted
Caused by: java.security.InvalidKeyException: Illegal key size
    at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) ~[na:1.8.0_121]
    at javax.crypto.Cipher.implInit(Cipher.java:805) ~[na:1.8.0_121]
    at javax.crypto.Cipher.chooseProvider(Cipher.java:864) ~[na:1.8.0_121]
    at javax.crypto.Cipher.init(Cipher.java:1396) ~[na:1.8.0_121]
    at javax.crypto.Cipher.init(Cipher.java:1327) ~[na:1.8.0_121]
    at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:113) ~[spring-security-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    ... 15 common frames omitted

Exception in Application init method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Cannot decrypt: key=admin.password
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:201)
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:165)
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:95)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer.initialize(BootstrapApplicationListener.java:370)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:611)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:348)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
    at com.****AppName.Main.springBootApplicationContext(Main.java:61)
    at com.****AppName.Main.init(Main.java:38)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
    ... 2 more
Caused by: java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key
    at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:120)
    at org.springframework.security.crypto.encrypt.AesBytesEncryptor.decrypt(AesBytesEncryptor.java:126)
    at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.decrypt(HexEncodingTextEncryptor.java:40)
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:193)
    ... 12 more
Caused by: java.security.InvalidKeyException: Illegal key size
    at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
    at javax.crypto.Cipher.implInit(Cipher.java:805)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
    at javax.crypto.Cipher.init(Cipher.java:1396)
    at javax.crypto.Cipher.init(Cipher.java:1327)
    at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:113)
    ... 15 more
Exception running application com.****AppName.Main

1 Ответ

0 голосов
/ 25 августа 2019

Проблема была решена путем изменения настроек предпочтений - где в Установленные JRE были отредактированы и JRE JDK был выбран.Мне пришлось изменить его на JRE системной установки.Я использую Eclipse IDE.


, и в случае, если вы также получаете эту ошибку: «Невозможно создать tempDir, java.io.tmpdir установлен в C: \ Windows \»

затем выберите «добавить переменные среды» вместо «переопределить переменные среды» в eclipse Run Configurations Setting.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...