spring-cloud / spring-cloud/spring-cloud-commons
Provided custom ssl context gets overriden when using autoconfiguration for apache httpclient
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 751
- Forks
- 744
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
Describe the bug
Spring Cloud version: 3.0.1
In our project I had to provide our own keystore/truststore for spring-cloud-openfeign with apache httpclient. I wanted to leave as much as I could for autoconfig and I also saw that RegistryBuilder is available 👇
But it looks like the SSLConnectionSocketFactory gets overriden when invoking DefaultApacheHttpClientConnectionManagerFactory.newConnectionManager(...). What looks suspicious to me are lines:
https://github.com/spring-cloud/spring-cloud-commons/blob/087b94a905c5428c89e4db22a6a284999d5d0a7d/spring-cloud-commons/src/main/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientConnectionManagerFactory.java#L77-L80
RegistryBuilder contains a map underneath, so when I would try to provide my own SSLConnectionSocketFactory then it gets overriden.
Not sure if this should be posted as a bug, but it gave me a bit of a head scratch. For now I've decided to extend the DefaultApacheHttpClientConnectionManagerFactory bean and pass to connection manager our own SSLContext. Maybe someone comes here and finds this helpful.
Sample
I've created a test case for this issue here 👇 Hope the sample gives clear information about what happens.
https://github.com/krasowskiM/spring-cloud-commons/commit/c986b81f918e736c0fdf7a7df6b7a85bc0faa2fe
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with spring-cloud-commons/src/main/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientConnectionManagerFactory.java around lines 77-80, then compare it with the RegistryBuilder setup in FeignAutoConfiguration.java around lines 165-171. Reproduce the behavior using the sample commit and verify that a caller-provided SSLConnectionSocketFactory is not overridden when creating the connection manager.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100