Spring Boot SSL works only on RestController Contstructor
Since I'm moving old architecture to a new Spring Boot solution I'm implementing the calls through @RestController.
Now, the FE needs to pass data to my @RestController which handles it, and make an old RPC-call to an old SoapWs.
The Rpc Ws-Endpoint uses Https, and needs a certificate.
So I've put everything in the Keystore and set the System.Properties accordingly.
Now the interesting part.
If I define the System properties in main spring boot Application Startup Class:
@Component
public class ApplicationStartup
implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(final ApplicationReadyEvent event) {
System.setProperty("javax.net.ssl.keyStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.ssl.trustStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
}
I can see them in the @RestController. I've checked them through System.getProperties(...) method and they are where they're supposed to be.
But the call to remote-rpc ws gives Handshake failure.
If set variables in the @RestController constructor....it works!
That's the only change.
I'm astonished, no clues at all.
java spring spring-boot rpc
|
show 4 more comments
Since I'm moving old architecture to a new Spring Boot solution I'm implementing the calls through @RestController.
Now, the FE needs to pass data to my @RestController which handles it, and make an old RPC-call to an old SoapWs.
The Rpc Ws-Endpoint uses Https, and needs a certificate.
So I've put everything in the Keystore and set the System.Properties accordingly.
Now the interesting part.
If I define the System properties in main spring boot Application Startup Class:
@Component
public class ApplicationStartup
implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(final ApplicationReadyEvent event) {
System.setProperty("javax.net.ssl.keyStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.ssl.trustStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
}
I can see them in the @RestController. I've checked them through System.getProperties(...) method and they are where they're supposed to be.
But the call to remote-rpc ws gives Handshake failure.
If set variables in the @RestController constructor....it works!
That's the only change.
I'm astonished, no clues at all.
java spring spring-boot rpc
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49
|
show 4 more comments
Since I'm moving old architecture to a new Spring Boot solution I'm implementing the calls through @RestController.
Now, the FE needs to pass data to my @RestController which handles it, and make an old RPC-call to an old SoapWs.
The Rpc Ws-Endpoint uses Https, and needs a certificate.
So I've put everything in the Keystore and set the System.Properties accordingly.
Now the interesting part.
If I define the System properties in main spring boot Application Startup Class:
@Component
public class ApplicationStartup
implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(final ApplicationReadyEvent event) {
System.setProperty("javax.net.ssl.keyStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.ssl.trustStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
}
I can see them in the @RestController. I've checked them through System.getProperties(...) method and they are where they're supposed to be.
But the call to remote-rpc ws gives Handshake failure.
If set variables in the @RestController constructor....it works!
That's the only change.
I'm astonished, no clues at all.
java spring spring-boot rpc
Since I'm moving old architecture to a new Spring Boot solution I'm implementing the calls through @RestController.
Now, the FE needs to pass data to my @RestController which handles it, and make an old RPC-call to an old SoapWs.
The Rpc Ws-Endpoint uses Https, and needs a certificate.
So I've put everything in the Keystore and set the System.Properties accordingly.
Now the interesting part.
If I define the System properties in main spring boot Application Startup Class:
@Component
public class ApplicationStartup
implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(final ApplicationReadyEvent event) {
System.setProperty("javax.net.ssl.keyStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.ssl.trustStore","/cert/clientkeystore.jks");
System.setProperty("javax.net.debug","ssl");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
}
I can see them in the @RestController. I've checked them through System.getProperties(...) method and they are where they're supposed to be.
But the call to remote-rpc ws gives Handshake failure.
If set variables in the @RestController constructor....it works!
That's the only change.
I'm astonished, no clues at all.
java spring spring-boot rpc
java spring spring-boot rpc
edited Nov 12 at 14:58
tom1299
598
598
asked Nov 9 at 13:43
Black.Jack
1,10221428
1,10221428
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49
|
show 4 more comments
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49
|
show 4 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226876%2fspring-boot-ssl-works-only-on-restcontroller-contstructor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226876%2fspring-boot-ssl-works-only-on-restcontroller-contstructor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
isn't there a typo? C:/ prefix is missing from trustStore path
– David Szalai
Nov 9 at 14:16
No it's just me amending things to publish code. Anyways corrected...thanks!
– Black.Jack
Nov 9 at 14:19
It is possible that ApplicationReadyEvent is too late to register such values, as SSLContext might already be initialized. Try putting them in @PostConstruct of the component.
– David Szalai
Nov 9 at 14:29
Yep that's more or less my "constructor approach". But other than specify every time I build the bean, I would fine-grained control the keystore.on a specific call.
– Black.Jack
Nov 9 at 14:39
I don't really understand what you mean by that. Why do you want to be able to change the trustStore for every call? Anyways, you can create multiple instances of docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html, and depending on what library you use for the remote call, inject an instance into that.
– David Szalai
Nov 9 at 14:49