-
-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
OTP: Update ssl to make receiving data before handshake easier #243
Comments
Maybe update |
Ranch 3.0 I guess? |
I am having a very strange bug while using ssl with PROXY protocol. Can't confirm it yet but it seems this could be the cause since it could trigger some unexpected state/race condition in ssl. There are too many moving parts in my infra so I can't create a minimal example yet. |
It's possible the hack is no longer working. Can you check which OTP version you are starting to have the problem with? |
OTP-23, cowboy 2.9.0. I can reliably trigger this by:
Then I dig around with I know ranch is expecting a PROXY header but I think ssl should also get to teardown the connection. All this happens in kubernetes so there's also that piece of the puzzle... Update 2: I can confirm that the load balancer is being dumb and it ... randomly injects a null byte at the beginning of the PROXY header.
It didn't get to call Update 3: Inspecting the stuck ssl process:
The down message is postponed when it's in the It seems using So now there are 3 blame targets:
I don't have the answer right now. |
This is clearly an OTP bug, if controlling_process, dies, the ssl process should die too.
I think I'll just do a manual close or something dumb like that on proxy header error. |
Filed a bug with OTP: erlang/otp#5239 |
Back to ranch, IMO, the cleanest fix would be to listen on gen_tcp and upgrade with ssl:handshake and force options to be separate: This would, of course, break all existing code. But it will remain safe for the foreseeable future. On my side, I need my app to work ASAP so I'll write custom |
Separating options is something that I had to do in Gun and would likely be a good idea in Ranch as well. But it's unlikely to come any time soon as it would for example require reworking RabbitMQ listener configuration. Or at least it means we can't replace |
There's also another way: hardcode a list of ssl options. There are not that many... We can filter at runtime. Alternatively, I think it's possible to extract the type definition from the module at runtime (or how does dialyzer work?). It's possible to filter out all ssl options. Edit: I just looked into dialyzer, it grabs core erlang from debug info embedded in the module and manipulate it. Seems complicated. A |
No the ssl options change too much. What can work is exporting the function in ssl that splits ssl/non-ssl options. |
Currently we are using a hack and that's fine but should eventually be made better. See https://bugs.erlang.org/browse/ERL-757 for a short discussion on the topic.
The text was updated successfully, but these errors were encountered: