openresty / stream-lua-nginx-module

Embed the power of Lua into NGINX TCP/UDP servers
BSD 2-Clause "Simplified" License
729 stars 198 forks source link

starttls #324

Open bjne opened 1 year ago

bjne commented 1 year ago

Does anyone have ideas on how starttls could be possible to accomplish with this module? Would likely need patches to nginx as well, but would be a nice feature that is currently missing

bjne commented 1 year ago

I was able to accomplish this now by preread and proxy, but would be extremely nice if one could:

listen 1234; # no ssl here

ssl_certificate_...

preread_by_lua_block {
  local sock = assert(ngx.req.socket(true))

  if sock:receive() == "STARTTLS" then
     sock:sslhandshake(...)
  end
}