-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: ssl: support for TLS-PSK #1167
base: master
Are you sure you want to change the base?
Conversation
@agentzh you're welcome! I would like to keep the callbacks separate as OpenSSL callback for TLS-PSK (set with SSL_CTX_set_psk_server_callback) is not re-entrant whereas cert_cb is, but it's your call :) By the way, have you noticed that some tests in t/129-ssl-socket.t seems to randomly fail due to a timeout when run by travis-ci? |
@vartiait Seems like I cannot rebase your branch to the latest master? See
Please do not use "git merge" in your branch and keep your git history strictly linear. Thank you! |
@vartiait Will you explain your use cases a bit? It seems that the use cases for this feature is very narrow. |
It seems to me that TLS-PSK is not a commonly used technology at all. AFAIK none of the web browsers on the market supports it. Additionally, NGINX, Apache, Python, Golang all lacks support to it in the standard TLS implementation as well. Maintaining such an obscure feature in the long term is probably not worth the effort, at least not until TLS-PSK become more adopted on the Internet. I would rather spend more time on migrating to OpenSSL 1.1 and add client side certificate support to cosocket. Since the later can do everything TLS-PSK can and is more secure and widely used. |
@agentzh sorry for that, I rebased my branch now. |
@agentzh @dndx Yes, TLS-PSK is mainly used with IoT (Internet of Things) devices which are performance-constrained with limited CPU power. There has apparently lately been also development of TLS-PSK support on NGINX side, http://mailman.nginx.org/pipermail/nginx-devel/2017-August/010430.html My case in on a telco/mobile side, where 3GPP has specified TLS-PSK as an authentication option 3GPP specification TS 33.222 - Generic Authentication Architecture (GAA); Access to network application functions using Hypertext Transfer Protocol over Transport Layer Security (HTTPS): http://www.etsi.org/deliver/etsi_ts/133200_133299/133222/14.00.00_60/ts_133222v140000p.pdf The product where we are using OpenResty is called Radiator GBA/BSF Pack: |
@vartiait That sounds interesting. Thanks for the info! |
@vartiait I still think we should use |
@agentzh okay, wouldn't that imply also a change to ngx_http_lua_ssl_cert_by_chunk to prevent it from creating a new thread with ngx_http_lua_new_thread when called by ngx_http_lua_ssl_psk_server_handler? |
@agentzh ah, okay, never mind, I now read what ngx_http_lua_new_thread, lua_newthread, ngx_http_lua_run_thread and lua_resume do. |
@agentzh @dndx I added a flag entered_psk_handler to ngx_http_lua_ssl_ctx_t which is set in TLS-PSK callback ngx_http_lua_ssl_psk_server_handler and when that flag is set, the context will be set to NGX_HTTP_LUA_CONTEXT_SSL_PSK (instead of NGX_HTTP_LUA_CONTEXT_SSL_CERT) in ngx_http_lua_ssl_cert_by_chunk. What do you think? |
I removed separate ssl_psk_by_lua* handlers and updated TLS-PSK server callback to use ssl_certificate_by_lua*. ssl_certificate_by_lua* handler will be called two times during TLS-PSK handshake, first time from ssl3_get_client_hello() (as with other ciphers) and the second time from ssl3_accept() when actually called to set the PSK key. |
@agentzh How could I get an exit code or a return code from ssl_certificate_by_lua* in order to return ngx.ERROR to terminate the handshake? I tried to copy ctx->exit_code to cctx->exit_code in ngx_http_lua_ssl_cert_by_chunk, but that change broke few test cases in t/139-ssl-cert-by.t so I reverted it. |
* implemented the ssl_psk_by_lua_block and ssl_psk_by_lua_file directives for controlling the NGINX downstream TLS-PSK handshake dynamically with Lua. * added pure C API for Lua library ngx.ssl in the lua-resty-core library for getting TLS-PSK client identity and setting TLS-PSK key. * added ssl_psk_identity_hint directive for setting TLS-PSK identity hint for the NGINX downstream TLS-PSK handshake. * added lua_ssl_psk_identity and lua_ssl_psk_key directives for setting the NGINX upstream TLS-PSK identity and key.
…entity_hint, lua_ssl_psk_identity and lua_ssl_psk_key directives.
@agentzh could you please comment the PR, I integrated TLS-PSK to ssl_certificate_by_lua*, are there some other tweaks needed? |
@vartiait I'll have a look as soon as I can manage. Thanks! |
What is the status here? |
This pull request is now in conflict :( |
f924579
to
fef2581
Compare
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.
Adds a support for TLS-PSK handshakes with following new directives to lua-nginx-module:
This is related to PR at lua-resty-core/pull/150