kernelsauce / turbo

Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.
http://turbo.readthedocs.io/
Apache License 2.0
528 stars 84 forks source link

Please implement Server Name Indication (SNI) for async.HTTPClient #274

Open Thomas12 opened 8 years ago

Thomas12 commented 8 years ago

I think it is not that complicated, you have to run SSL_set_tlsext_host_name(.., ...).

Would help me a lot as newer ssl-servers often have many domains on the same ip and the async HTTP client exits with handshake error.

Thank you very much!

Thomas

Thomas12 commented 7 years ago

Here are some rudimentary parts for SNI, I know it is very far from being a "patch" at all! The reason is that I don't see how to access the hostname from within ssl_do_handshake. For me, this is a "hack", it works for my case but this feature could be interesting for others, too and the details below might save you some time when implementing it the generic way:

in cdef.lua: Add: long SSL_ctrl(SSL s, int cmd, long larg, void *parg);

in ssl_create_client_context: Replace with: meth = sslv or lssl.TLSv1_2_client_method()

in ssl_do_handshake: Add: host="https://www.github.com/foo":match('^%w+://([^/]+)')..string.char(0) local c_str = ffi.new("char[?]", #host) ffi.copy(c_str, host) lssl.SSL_ctrl(ssl, 55, 0, c_str) --SSL_CTRL_SET_TLSEXT_HOSTNAME = 55