Title: createSocket with consumed InputStream and com.sun.net.ssl.requireCloseNotify throws SocketException · Issue #2142 · bcgit/bc-java · GitHub
Open Graph Title: createSocket with consumed InputStream and com.sun.net.ssl.requireCloseNotify throws SocketException · Issue #2142 · bcgit/bc-java
X Title: createSocket with consumed InputStream and com.sun.net.ssl.requireCloseNotify throws SocketException · Issue #2142 · bcgit/bc-java
Description: When the createSocket factory method is used with a non-null InputStream consumed argument, a SequenceInputStream is created. One consideration with using SequenceInputStream is the following After each input stream from the enumeration ...
Open Graph Description: When the createSocket factory method is used with a non-null InputStream consumed argument, a SequenceInputStream is created. One consideration with using SequenceInputStream is the following After...
X Description: When the createSocket factory method is used with a non-null InputStream consumed argument, a SequenceInputStream is created. One consideration with using SequenceInputStream is the following After...
Opengraph URL: https://github.com/bcgit/bc-java/issues/2142
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"createSocket with consumed InputStream and com.sun.net.ssl.requireCloseNotify throws SocketException","articleBody":"When the createSocket factory method is used with a non-null `InputStream consumed` argument, a [SequenceInputStream is created](https://github.com/bcgit/bc-java/blob/main/tls/src/main/java/org/bouncycastle/jsse/provider/ProvSSLSocketWrap.java#L593). One consideration with using SequenceInputStream is the following\n\n> After each input stream from the enumeration is exhausted, it is closed by calling its close method.\n\nhttps://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/SequenceInputStream.html\n\nIf a client opens a connection, handshakes successfully, writes some data, then closes the connection without sending close_notify, this will typically result in a [TlsNoCloseNotifyException being thrown](https://github.com/bcgit/bc-java/blob/main/tls/src/main/java/org/bouncycastle/tls/TlsProtocol.java#L909). If the [`com.sun.net.ssl.requireCloseNotify`](https://github.com/bcgit/bc-java/blob/main/tls/src/main/java/org/bouncycastle/jsse/provider/JsseUtils.java#L79-L80) is set to false, then instead we [send our own close_notify](https://github.com/bcgit/bc-java/blob/main/tls/src/main/java/org/bouncycastle/tls/TlsProtocol.java#L880). If this property is used in combination with the `InputStream consumed` argument, BC will try to write to a closed socket and throw a SocketException\n\n```\njava.net.SocketException: Socket closed\nsun.nio.ch.NioSocketImpl.ensureOpenAndConnected (NioSocketImpl.java:165)\nsun.nio.ch.NioSocketImpl.beginWrite (NioSocketImpl.java:371)\nsun.nio.ch.NioSocketImpl.implWrite (NioSocketImpl.java:416)\nsun.nio.ch.NioSocketImpl.write (NioSocketImpl.java:445)\nsun.nio.ch.NioSocketImpl$2.write (NioSocketImpl.java:831)\njava.net.Socket$SocketOutputStream.write (Socket.java:1035)\norg.bouncycastle.tls.RecordStream.writeRecord (RecordStream.java:309)\norg.bouncycastle.tls.TlsProtocol.safeWriteRecord (TlsProtocol.java:950)\norg.bouncycastle.tls.TlsProtocol.raiseAlertWarning (TlsProtocol.java:1721)\norg.bouncycastle.tls.TlsProtocol.handleClose (TlsProtocol.java:300)\norg.bouncycastle.tls.TlsProtocol.safeReadRecord (TlsProtocol.java:891)\norg.bouncycastle.tls.TlsProtocol.readApplicationData (TlsProtocol.java:842)\norg.bouncycastle.jsse.provider.ProvSSLSocketWrap$AppDataInput.read (ProvSSLSocketWrap.java:801)\njava.io.SequenceInputStream.read (SequenceInputStream.java:198)\njava.io.BufferedInputStream.fill (BufferedInputStream.java:244)\njava.io.BufferedInputStream.read1 (BufferedInputStream.java:284)\njava.io.BufferedInputStream.read (BufferedInputStream.java:343)\n```","author":{"url":"https://github.com/ulrokx","@type":"Person","name":"ulrokx"},"datePublished":"2025-08-06T21:19:16Z","url":"https://github.com/bcgit/bc-java/issues/2142"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2f221b9d-3a95-dee2-ceb3-7ca2c9bd6d64 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B554:175A3:7598AE:9F3CE9:6AFBFB69 |
| html-safe-nonce | 1c4ed522ad57214d615670e3b252801a74c868d6b3accf4818bade26da304611 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTU0OjE3NUEzOjc1OThBRTo5RjNDRTk6NkFGQkZCNjkiLCJ2aXNpdG9yX2lkIjoiNDg0ODYyMjg2ODk3MzIyMjc2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f7927b1b7aa64a6a5d9a7b5f762356d0d2c9950f584907dd4e7fa54f1c704e26 |
| hovercard-subject-tag | issue:3298113781 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bcgit/bc-java/2142/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4c9ed30eedaccaade2fe73e80ce9d42dbecdcd7ebbf9c7f3fb5916f29748776/bcgit/bc-java/issues/2142 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4c9ed30eedaccaade2fe73e80ce9d42dbecdcd7ebbf9c7f3fb5916f29748776/bcgit/bc-java/issues/2142 |
| og:image:alt | When the createSocket factory method is used with a non-null InputStream consumed argument, a SequenceInputStream is created. One consideration with using SequenceInputStream is the following After... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ulrokx |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/bcgit/bc-java git https://github.com/bcgit/bc-java.git |
| octolytics-dimension-user_id | 4566970 |
| octolytics-dimension-user_login | bcgit |
| octolytics-dimension-repository_id | 10416648 |
| octolytics-dimension-repository_nwo | bcgit/bc-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 10416648 |
| octolytics-dimension-repository_network_root_nwo | bcgit/bc-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width