-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: compilation against OpenSSL 1.1.0 #4215
Conversation
src/openssl/lib_crypto.cr
Outdated
@@ -1,5 +1,8 @@ | |||
@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'`")] | |||
lib LibCrypto | |||
OPENSSL_102 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version 1.0.2 && printf %s true` == "true" %} | |||
OPENSSL_110 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version 1.1.0 && printf %s true` == "true" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the command is missing libcrypto
, pkg-config libcrypto --atleast-version ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I fixed the pkg-config
commands, I hope they're fine, now.
src/openssl/lib_ssl.cr
Outdated
@@ -2,6 +2,9 @@ require "./lib_crypto" | |||
|
|||
@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'`")] | |||
lib LibSSL | |||
OPENSSL_102 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version=102 libssl && printf %s true` == "true" %} | |||
OPENSSL_110 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version=110 libssl && printf %s true` == "true" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto with s/libcrypto/libssl/
, also I wonder whether those should be --exact-version
or --max-version
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to have greater-than / lower-than triggers, which won't break on a new OpenSSL version (unless they removed symbols).
a1ced87
to
be8083e
Compare
src/openssl/lib_crypto.cr
Outdated
@@ -1,5 +1,8 @@ | |||
@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'`")] | |||
lib LibCrypto | |||
OPENSSL_102 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.0.2 libcrypto && printf %s true` == "true" %} | |||
OPENSSL_110 = {% `command -v pkg-config > /dev/null && pkg-config --atleast-version=1.1.0 libcrypto && printf %s true` == "true" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured out why CI fails, the assignment this way is runtime and thus always truthy at compile time, since it expands to the AST node. Doing an assignment to a constant at compile time seems to be not (no longer?) possible :(
lib LibCrypto | ||
OPENSSL_102 = false | ||
end | ||
{% end %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I figured that out in the past and that's where this workaround comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oookay... I'll revert and add a note about this trick so I won't inadvertently remove it again.
Thanks for the input!
8bfb10f
to
0020328
Compare
0020328
to
1658c31
Compare
After compiling different OpenSSL versions and a session of trial and error, I found out how to make things work:
So, now, I tested against OpenSSL 1.0.1, 1.0.2 and 1.1.0. |
❤️ thank you! |
OpenSSL 1.1.0 introduced some breaking changes:
TLS_method
has been added whileSSLv23_method
was removed.fixes #4204