feature: ngx_http_lua_ffi_ssl_set_ciphers().#2513
Open
climagabriel wants to merge 1 commit into
Open
Conversation
Sets the connection's TLS <= 1.2 cipher list and/or TLS 1.3 ciphersuites from ssl_client_hello_by_lua*, e.g. keyed on the client hello server name. Both strings are validated on a scratch SSL_CTX before being applied to the connection, because a failed SSL_set_cipher_list() still installs the parsed list on the connection (emptying the TLS <= 1.2 list on unknown tokens) and leaves the thread error queue dirty, which makes SSL_do_handshake() report failure after the callback returns. The guarantee: if ngx_http_lua_ffi_ssl_set_ciphers returns NGX_ERROR for an invalid ciphers and/or ciphersuites string, the connection's SSL object is left exactly as it was -- cipher list, ciphersuites, and thread error queue all untouched -- so the handshake proceeds with whatever the connection already had, which is the default list inherited from the vhost's SSL_CTX (ssl_ciphers/ssl_conf_command). See openssl/openssl#7759 for the check-after- install behaviour of SSL_set_cipher_list() and https://docs.openssl.org/3.0/man3/SSL_get_error/ for the empty-queue requirement.
Contributor
Author
|
Lua API + docs + tests: openresty/lua-resty-core#535 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
ngx_http_lua_ffi_ssl_set_ciphers()to set the connection's TLS <= 1.2 cipher list and/or TLS 1.3 ciphersuites fromssl_client_hello_by_lua*, e.g. keyed on the client hello server name. Complementsngx_http_lua_ffi_ssl_set_protocols().Both strings are validated on a scratch
SSL_CTXbefore being applied to the connection, because a failedSSL_set_cipher_list()still installs the parsed list on the connection (emptying the TLS <= 1.2 list on unknown tokens, see the check-after-install discussion in openssl/openssl#7759) and leaves the thread error queue dirty, which makesSSL_do_handshake()report failure after the callback returns (SSL_get_error() requires an empty queue).The guarantee: if
ngx_http_lua_ffi_ssl_set_ciphersreturnsNGX_ERRORfor an invalid ciphers and/or ciphersuites string, the connection's SSL object is left exactly as it was -- cipher list, ciphersuites, and thread error queue all untouched -- so the handshake proceeds with whatever the connection already had, which is the default list inherited from the server'sSSL_CTX(ssl_ciphers/ssl_conf_command).Lua API + docs + tests: companion PR openresty/lua-resty-core (link in first comment).