AbstractSslConfigurer does not close the InputStream opened by URL.openStream() (trusted-x509-certificates / key-store)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- java, spring-boot
Línea de trabajo
Lee AbstractSslConfigurer.getTrustedX509CertificatesForTrustManager() y AbstractSslConfigurer.createKeyStore(), donde el issue identifica los streams que no se cierran. Envuelve cada url.openStream() en try-with-resources y revisa las pruebas existentes para los certificados de confianza y la carga del key-store. Se completa cuando ambos streams se cierran después de usarse y pasan las pruebas pertinentes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 4.9k
- Forks
- 3.5k
- Merge medio
- 1 d 13 h
- PR fusionados (30 d)
- 14
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de spring-cloud/spring-cloud-gateway
-
RequestRateLimiterGatewayFilterFactory commits 429 response instead of throwingPosiblemente ocupada @seonwooj0810 la tomó hace 175 días. Abiertowaiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
spring-cloud/spring-cloud-gateway#4175 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add @Order annotation to gatewayRestClientCustomizer BeanPosiblemente ocupada @CheHyeonYeong la tomó hace 247 días. Abiertoenhancement help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
spring-cloud/spring-cloud-gateway#3626 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Ambiguity in section 19 of the documentation - Spring Cloud Gateway - Custom Route PredicatePosiblemente ocupada @won-seoop la tomó hace 173 días. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
spring-cloud/spring-cloud-gateway#3463 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
waiting for feedback
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
spring-cloud/spring-cloud-gateway#4394 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Use a list of CIDR for trusted-proxiesQuizá libre de nuevo @vasipallyn la tomó hace 16 días y no hay ningún pull request abierto. Abiertowaiting-for-triage
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
spring-cloud/spring-cloud-gateway#4371 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de spring-cloud/spring-cloud-gateway
Issues similares
-
area:cpan-port area:performance bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
fglock/PerlOnJava#2230 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
federicoiosue/Omni-Notes#1044 ·
-
Industrial Center Text TypoAbiertoBug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día