servername_cb (and others) do odd things with lambda/proc?
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 276
- Forks
- 200
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 7
Description
Might be related to https://bugs.ruby-lang.org/issues/12705
When I do something like this:
server_context = OpenSSL::SSL::SSLContext.new.tap do |context|
context.servername_cb = proc {|socket, name|
if hosts.include? name
OpenSSL::SSL::SSLContext.new.tap do |context|
context.cert = certificates[name]
context.key = keys[name]
end
end
}
end
it works. But if I change proc to lambda, it fails with ArgumentError: wrong number of arguments (given 1, expected 2).
server_context = OpenSSL::SSL::SSLContext.new.tap do |context|
context.servername_cb = lambda {|socket, name|
if hosts.include? name
OpenSSL::SSL::SSLContext.new.tap do |context|
context.cert = certificates[name]
context.key = keys[name]
end
end
}
end
However, I feel like both should work. Does proc unwrap array implicitly?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two callback forms through OpenSSL::SSL::SSLContext#servername_cb, comparing how the proc and lambda receive socket and name. Read the callback behavior around SSLContext.new and servername_cb, then confirm that the corrected behavior handles both forms with the expected arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ruby
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100