AbstractSslConfigurer does not close the InputStream opened by URL.openStream() (trusted-x509-certificates / key-store)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java, spring-boot
調査の方向性
issueで閉じられていないストリームが指摘されている AbstractSslConfigurer.getTrustedX509CertificatesForTrustManager() と AbstractSslConfigurer.createKeyStore() を読んでください。各 url.openStream() を try-with-resources で囲み、信頼済み証明書と key-store の読み込みに関する既存のテストを確認してください。両方のストリームが使用後に閉じられ、関連するテストが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 4.9k
- フォーク
- 3.5k
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-cloud/spring-cloud-gateway のほかの issue
-
RequestRateLimiterGatewayFilterFactory commits 429 response instead of throwing対応中かも @seonwooj0810 が 175 日前に担当しました。 オープンwaiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spring-cloud/spring-cloud-gateway#4175 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add @Order annotation to gatewayRestClientCustomizer Bean対応中かも @CheHyeonYeong が 247 日前に担当しました。 オープンenhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spring-cloud/spring-cloud-gateway#3626 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Ambiguity in section 19 of the documentation - Spring Cloud Gateway - Custom Route Predicate対応中かも @won-seoop が 173 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
spring-cloud/spring-cloud-gateway#3463 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
waiting for feedback
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
spring-cloud/spring-cloud-gateway#4394 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Use a list of CIDR for trusted-proxies再び着手できるかも @vasipallyn が 16 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンwaiting-for-triage
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
spring-cloud/spring-cloud-gateway#4371 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
spring-cloud/spring-cloud-gateway の issue をすべて見る
似ている issue
-
area:cpan-port area:performance bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fglock/PerlOnJava#2230 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
federicoiosue/Omni-Notes#1044 ·
-
Bug
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信