AbstractSslConfigurer does not close the InputStream opened by URL.openStream() (trusted-x509-certificates / key-store)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java, spring-boot
Direzione di ricerca
Leggi AbstractSslConfigurer.getTrustedX509CertificatesForTrustManager() e AbstractSslConfigurer.createKeyStore(), dove l’issue individua gli stream non chiusi. Racchiudi ogni url.openStream() in try-with-resources e controlla i test esistenti per i certificati attendibili e il caricamento del key-store. Il lavoro è completato quando entrambi gli stream vengono chiusi dopo l’uso e i test pertinenti passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
AbstractSslConfigurer.getTrustedX509CertificatesForTrustManager() passes url.openStream() directly to
CertificateFactory.generateCertificates(...), and AbstractSslConfigurer.createKeyStore() passes url.openStream()
directly to KeyStore.load(...). Neither stream is closed (no try-with-resources and no close() call in the class).
// getTrustedX509CertificatesForTrustManager()
Collection<? extends Certificate> certs = certificateFactory.generateCertificates(url.openStream());
// createKeyStore()
store.load(url.openStream(), ...);
Neither CertificateFactory.generateCertificates nor KeyStore.load documents that it closes the stream it is
given, and in practice the underlying file handle stays open after the call (observed on Windows, see below) until
the unreferenced stream is garbage-collected.
Impact
- With a
file:location, the file handle stays open after the routingHttpClientis built. On Windows the
certificate / key-store file cannot be deleted or replaced while the handle is open
("The process cannot access the file because it is being used by another process"). - With
jar:orhttp(s):locations, the connection / jar handle stays open in the same way. - The leak is bounded (once per configured file when the
HttpClientis created), but it is still a resource leak.
Versions
- Spring Cloud Gateway Server WebFlux 5.0.5 (also present on
mainas of 2026-11-30) - Java 17
To reproduce
- Configure
spring.cloud.gateway.server.webflux.httpclient.ssl.trusted-x509-certificates[0]=file:<path>/ca.crt
(a self-signed CA certificate in PEM form). - Start the application so that the routing
HttpClientis created. - On Windows, try to delete
<path>/ca.crtfrom the same JVM (for example in a test cleanup step).
The deletion fails until a GC happens to clean up the unreferenced stream.
Suggested fix
Open the streams in try-with-resources:
try (InputStream in = url.openStream()) {
Collection<? extends Certificate> certs = certificateFactory.generateCertificates(in);
allCerts.addAll(certs);
}
and likewise in createKeyStore():
try (InputStream in = url.openStream()) {
store.load(in, ...);
}
Configurations that use ssl-bundle are not affected, because that path obtains the trust managers from the
Spring Boot SslBundle.
- Lingua principale
- Java
- Stelle
- 4.9k
- Fork
- 3.5k
- Merge medio
- 1g 13h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-cloud/spring-cloud-gateway
-
RequestRateLimiterGatewayFilterFactory commits 429 response instead of throwingForse già presa @seonwooj0810 l’ha presa 175 giorni fa. Apertawaiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
spring-cloud/spring-cloud-gateway#4175 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add @Order annotation to gatewayRestClientCustomizer BeanForse già presa @CheHyeonYeong l’ha presa 247 giorni fa. Apertaenhancement help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
spring-cloud/spring-cloud-gateway#3626 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Ambiguity in section 19 of the documentation - Spring Cloud Gateway - Custom Route PredicateForse già presa @won-seoop l’ha presa 173 giorni fa. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
spring-cloud/spring-cloud-gateway#3463 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
waiting for feedback
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
spring-cloud/spring-cloud-gateway#4394 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Use a list of CIDR for trusted-proxiesForse di nuovo libera @vasipallyn l’ha presa 16 giorni fa e non c’è nessuna pull request aperta. Apertawaiting-for-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
spring-cloud/spring-cloud-gateway#4371 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di spring-cloud/spring-cloud-gateway
Issue simili
-
area:cpan-port area:performance bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fglock/PerlOnJava#2230 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
federicoiosue/Omni-Notes#1044 ·
-
Industrial Center Text TypoApertaBug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno