Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing native hints for TextEncryptorUtils #1245

Closed
nhmarujo opened this issue Jun 12, 2023 · 2 comments
Closed

Missing native hints for TextEncryptorUtils #1245

nhmarujo opened this issue Jun 12, 2023 · 2 comments
Assignees
Labels
Milestone

Comments

@nhmarujo
Copy link

nhmarujo commented Jun 12, 2023

Describe the bug
When I build a native image with a jks file to use with Spring Cloud Decryption it fails to boot with the following error:

21:26:44.825 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
java.lang.NullPointerException: null
        at org.springframework.cloud.context.encrypt.EncryptorFactory.create(EncryptorFactory.java:55)
        at org.springframework.cloud.bootstrap.encrypt.TextEncryptorUtils.getTextEncryptor(TextEncryptorUtils.java:66)
        at org.springframework.cloud.bootstrap.encrypt.TextEncryptorUtils.decrypt(TextEncryptorUtils.java:51)
        at org.springframework.cloud.bootstrap.encrypt.DecryptEnvironmentPostProcessor.postProcessEnvironment(DecryptEnvironmentPostProcessor.java:66)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:109)
        at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:94)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
        at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
        at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
        at java.base@17.0.6/java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
        at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:355)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)
        at com.sample.jksnative.JksNativeApplication.main(JksNativeApplication.java:16)

Originally I had a different error that was reported and got fixed on the framework itself, but now I get this new different error and I was advised to report it here.

I manage to make the application work if I register the following hint:

hints.reflection()
    .registerTypeIfPresent(classLoader, "org.springframework.security.rsa.crypto.RsaSecretEncryptor", INVOKE_DECLARED_CONSTRUCTORS);

Looks like spring cloud is missing to register some hints. Could you please take a look if that is the case? Thank you

Sample
I patched the original sample I used for spring-projects/spring-framework#30628 and created a new branch on which you can replicate the error I showed previously.

@OlgaMaciaszek
Copy link
Collaborator

Hi. @nhmarujo. Thanks for reporting the issue and suggesting a fix. I have added the missing hint and verified the solution.

@nhmarujo
Copy link
Author

Hi @OlgaMaciaszek. Thank you so much for the fix 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Status: Done
Development

No branches or pull requests

3 participants