fix: don't delegate client alias choosing for ssl bundles#49838
fix: don't delegate client alias choosing for ssl bundles#49838MezinK wants to merge 3 commits intospring-projects:mainfrom
Conversation
Signed-off-by: MezinK <mezinkocahal@hotmail.com>
4a3acd4 to
427cdd3
Compare
|
We should consider the discussion in #44629 when reviewing this proposal. |
I don't think it picks the first alias. AIUI, it picks the first matching alias. Regardless, when looking at #44629, I had this concern:
I still have that concern and the change proposed here does not address it. If we want to provide some control over the alias that's used on the client-side rather than delegating to the matching performed by |
Perhaps, this can be added under What do you think? |
|
That would allow users to opt in but I wonder if some may need separate aliases for the client side and for the server side. I'm not sure how likely it is that someone would have an SSL setup that requires that configurability but perhaps we should deprecate |
|
I've debugged the flow of the
Here, we are in the CertificateATest.java class, but you can see that aliases[0] is equal to "certificate-b", therefore the test has the unexpected results. |
|
We discussed this today. We'd like to deprecate |
|
Sure, I can do that |
…ias-support-for-client-ssl-bundles
Signed-off-by: MezinK <mezinkocahal@hotmail.com>
|
@wilkinsona I have yet to add tests but I caught a case where I got a bit confused. I marked it with "TODO" in the code. because this would currently be valid: spring:
ssl:
bundle:
jks:
certificate:
key:
client-alias: "client-alias" # what happens here? there may only be one certificate at a time if the aliases are different
server-alias: "server-alias"
keystore:
location: classpath:ssl/shared.p12
password: ...I assume, we want to load either a client alias or a server alias, but never both (unless they have the same value) if this is the case, does it really make sense to branch it out into client-alias and server-alias? |
|
When both are configured, my expectation is that we'd pass both into |

Currently, the
.key.aliasspecified inside of an SSL Bundle is not taken into account when dealing with client certificates.This causes the delegate (usually
SunX509KeyManagerImpl) to just pick the first alias it finds.For requests requiring mTLS, this can cause issues if the certificates are inside of a shared keystore, as you may not get the certificate that you would want.
I have created an example repo demonstrating this behavior:
https://github.com/MezinK/spring-boot-mtls-demo