Skip to content
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: add FFI function to set SSL ciphers #961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feature: ssl: add FFI function to set SSL ciphers #961

wants to merge 1 commit into from

Conversation

ghedo
Copy link
Contributor

@ghedo ghedo commented Jan 19, 2017

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

@ghedo
Copy link
Contributor Author

ghedo commented Feb 2, 2017

@agentzh @doujiang24 ping? This seems pretty straightforward.

@agentzh
Copy link
Member

agentzh commented Feb 2, 2017

@ghedo Sorry for the delay on our side. This PR looks good to me :) @doujiang24 ?

@agentzh
Copy link
Member

agentzh commented Feb 2, 2017

@ghedo Have you created a PR for lua-resty-core yet?

@ghedo
Copy link
Contributor Author

ghedo commented Feb 2, 2017

Made openresty/lua-resty-core#86 now.


if (!SSL_set_cipher_list(ssl_conn, ciphers)) {
*err = "SSL_set_cipher_list() failed";
goto failed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we can omit the goto here?Just move the failed code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ghedo
Copy link
Contributor Author

ghedo commented Mar 18, 2017

@agentzh @doujiang24 ping? Is there anything else needed here?

@ghedo
Copy link
Contributor Author

ghedo commented Jul 13, 2017

@agentzh @doujiang24 it's now been almost 6 months since this and openresty/lua-resty-core#86 were opened, any news?

@agentzh
Copy link
Member

agentzh commented Jul 13, 2017

@ghedo Sorry for the long delay on our side. We'll look into this as soon as we can manage. Thanks for your understanding!

return NGX_ERROR;
}

if (!SSL_set_cipher_list(ssl_conn, ciphers)) {
Copy link
Member

@agentzh agentzh Nov 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghedo I wonder if you really need per-connection ciphers. Maybe you just need a per-domain cipher suite? If it's the latter, then we can just reuse a domain-level SSL ctx to avoid per-request cipher name parsing and setting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we can simply set a parsed SSL cipher suite C data structure to avoid the string parsing here on a hot code path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree that calling SSL_set_cipher_list on a per request basis is a terrible idea as it both has lots of malloc along the way and the cipher search algorithm is linear.

Better way of doing this is to store the cipher stack created by OpenSSL once and reuse them later in new connections with some kind of Lua handle (e.g. cdata).

There may be other way that's better but I haven't looked too much into other OpenSSL cipher related APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, missed these comments...

Anyway, the function is intended to be used in ssl_cert_by_lua, so per-connection, not per-request, and even then not all connections (otherwise you might as well use ssl_protocols in the config).

AFAICT there's no OpenSSL API that would allow you to parse a cipher string into an array or stack of SSL_CIPHER, without actually changing the cipher list on an SSL or SSL_CTX struct. And even then, there's no OpenSSL API to set a cipher list from an array or stack of SSL_CIPHER. Did you have anything specific in mind?

In any case the overhead of SSL_set_cipher_list() is really not that bad, and even if it was too slow/heavy for whatever use case (which would likely prevent other OpenResty APIs from being used as well), nobody would be forced to use this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghedo Well, I think we are just trying to do it right :) BTW, have you actually measured the overhead of parsing and loading long cipher strings in this context?

return NGX_ERROR;
}

if (!SSL_set_cipher_list(ssl_conn, ciphers)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree that calling SSL_set_cipher_list on a per request basis is a terrible idea as it both has lots of malloc along the way and the cipher search algorithm is linear.

Better way of doing this is to store the cipher stack created by OpenSSL once and reuse them later in new connections with some kind of Lua handle (e.g. cdata).

There may be other way that's better but I haven't looked too much into other OpenSSL cipher related APIs.

@mergify
Copy link

mergify bot commented Jun 26, 2020

This pull request is now in conflict :(

@mergify mergify bot added the conflict label Jun 26, 2020
@mergify mergify bot removed the conflict label Mar 20, 2023
@mergify
Copy link

mergify bot commented Mar 20, 2023

This pull request is now in conflict :(

@mergify mergify bot added the conflict label Mar 20, 2023
@mergify mergify bot removed the conflict label May 10, 2023
@mergify
Copy link

mergify bot commented May 10, 2023

This pull request is now in conflict :(

@mergify mergify bot added the conflict label May 10, 2023
@mergify mergify bot removed the conflict label Sep 23, 2023
@mergify
Copy link

mergify bot commented Sep 23, 2023

This pull request is now in conflict :(

@mergify mergify bot added the conflict label Sep 23, 2023
@mergify mergify bot removed the conflict label Mar 6, 2024
Copy link

mergify bot commented Mar 6, 2024

This pull request is now in conflict :(

@mergify mergify bot added the conflict label Mar 6, 2024
@mergify mergify bot removed the conflict label May 27, 2024
Copy link

mergify bot commented May 27, 2024

This pull request is now in conflict :(

@mergify mergify bot added the conflict label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants