SSLSocket#syswrite no longer raises IOError after IO#close

未关闭
#1,156 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, ruby
领域
backend, security

调研方向

Start by tracing how SSLSocket#syswrite reaches SSL_write() and how the underlying socket's close is handled, using the reported regression from #1105 as context. Reproduce the supplied UNIXSocket pair example, then add or locate a regression test that checks writing after close raises IOError; the issue names no source or test files, so expect to read around the socket implementation first.

由索引模型根据 Issue 内容生成。

描述

Since bf1a41904e051d31dbb1648019787fe336cec1c8 (#1105), SSLSocket#syswrite no longer raises IOError after IO#close on the underlying socket. SSL_write() still uses the old file descriptor number, so if a new socket gets the same number, the TLS record goes to the new socket.

require "openssl"
require "socket"

key = OpenSSL::PKey::EC.generate("prime256v1")
cert = OpenSSL::X509::Certificate.new
cert.public_key = key
cert.not_before = cert.not_after = Time.now
cert.sign(key, "SHA256")
ctx = OpenSSL::SSL::SSLContext.new
ctx.add_certificate(cert, key)

s1, s2 = UNIXSocket.pair
Thread.new { OpenSSL::SSL::SSLSocket.new(s1, ctx).accept }
ssl = OpenSSL::SSL::SSLSocket.new(s2)
ssl.connect

fd = s2.fileno
s2.close
a, b = UNIXSocket.pair
a.fileno == fd #=> true
ssl.syswrite("hello") #=> 5
b.read_nonblock(100) #=> "\x17\x03\x03\x00\x16..."

I checked the open PRs, but none of them corrects the issue.

主要语言
C
星标
276
派生
205
平均合并
21 小时 17 分钟
30 天内合并 PR
17

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/openssl 的其他 Issue

查看 ruby/openssl 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。