4finance / micro-infra-spring

Repository containing default microservice infrastructure set up using Spring configuration
Apache License 2.0
203 stars 49 forks source link

On decryption error application fails without stacktrace #314

Closed szpak closed 9 years ago

szpak commented 9 years ago

As reported by @dst on decryption error (there because of lack of JCE) only one line error is displayed and the application startup failes.

o.s.c.b.c.PropertySourceBootstrapConfiguration | Could not locate PropertySource: Unable to initialize due to invalid secret key

It would be good to have a stacktrace. Reported for 0.8.10.

szpak commented 9 years ago

The problem cannot be reproduced locally with 0.8.10 (with spring-cloud-config 1.0.0.RC2) and current master (1.0.0.RELEASE) with Oracle Java 1.7.0 (without JCE) - beauty stacktrace is printed.

dst commented 9 years ago

Not ideal, but it looks better:

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:483)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key
    at org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:110)
    at org.springframework.security.crypto.encrypt.AesBytesEncryptor.decrypt(AesBytesEncryptor.java:74)
    at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.decrypt(HexEncodingTextEncryptor.java:40)
    at com.ofg.infrastructure.property.FileSystemLocator.decrypt(FileSystemLocator.java:95)
    at com.ofg.infrastructure.property.FileSystemLocator.decryptIfEncrypted(FileSystemLocator.java:87)
    at com.ofg.infrastructure.property.FileSystemLocator.decrypt(FileSystemLocator.java:80)
    at com.ofg.infrastructure.property.FileSystemLocator.toPropertySource(FileSystemLocator.java:67)
    at com.ofg.infrastructure.property.FileSystemLocator.locate(FileSystemLocator.java:41)
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:81)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:567)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at com.ofg.worldpay.Application.main(Application.java:23)
    ... 6 more
Caused by: java.security.InvalidKeyException: Illegal key size
    at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1034)
    at javax.crypto.Cipher.implInit(Cipher.java:800)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:859)
    at javax.crypto.Cipher.init(Cipher.java:1370)
    at javax.crypto.Cipher.init(Cipher.java:1301)
    at
org.springframework.security.crypto.encrypt.CipherUtils.initCipher(CipherUtils.java:105)
    ... 17 more