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

start at compiling ruby-openssl with openssl 3.0.0 beta1 #445

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
- openssl-1.0.2u # EOL
- openssl-1.1.0l # EOL
- openssl-1.1.1j
- openssl-3.0.0-beta1
- libressl-3.1.5
- libressl-3.2.4
steps:
Expand Down
3 changes: 3 additions & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def find_openssl_library
have_func("EVP_MD_CTX_new")
have_func("EVP_MD_CTX_free")
have_func("EVP_MD_CTX_pkey_ctx")
have_func("EVP_MD_CTX_get_pkey_ctx")
have_func("X509_STORE_get_ex_data")
have_func("X509_STORE_set_ex_data")
have_func("X509_STORE_get_ex_new_index")
Expand All @@ -159,11 +160,13 @@ def find_openssl_library
have_func("TS_STATUS_INFO_get0_text")
have_func("TS_STATUS_INFO_get0_failure_info")
have_func("TS_VERIFY_CTS_set_certs")
have_func("TS_VERIFY_CTX_set_certs")
have_func("TS_VERIFY_CTX_set_store")
have_func("TS_VERIFY_CTX_add_flags")
have_func("TS_RESP_CTX_set_time_cb")
have_func("EVP_PBE_scrypt")
have_func("SSL_CTX_set_post_handshake_auth")
have_func("ERR_get_error_all")

# added in 1.1.1
have_func("EVP_PKEY_check")
Expand Down
17 changes: 15 additions & 2 deletions ext/openssl/openssl_missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

#include "ruby/config.h"

/* added in 3.0.0 */
/* Notes:
HAVE_EVP_MD_CTX_GET_PKEY_CTX replaces HAVE_EVP_MD_CTX_PKEY_CTX

HAVE_TS_VERIFY_CTX_SET_CERTS replaces HAVE_TS_VERIFY_CTS_SET_CERTS
*/

/* added in 1.1.0 */
#if !defined(HAVE_EVP_MD_CTX_NEW)
# define EVP_MD_CTX_new EVP_MD_CTX_create
Expand All @@ -21,7 +28,7 @@
# define EVP_MD_CTX_free EVP_MD_CTX_destroy
#endif

#if !defined(HAVE_EVP_MD_CTX_PKEY_CTX)
#if !defined(HAVE_EVP_MD_CTX_PKEY_CTX) && !defined(HAVE_EVP_MD_CTX_GET_PKEY_CTX)
# define EVP_MD_CTX_pkey_ctx(x) (x)->pctx
#endif

Expand Down Expand Up @@ -195,7 +202,7 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
# define TS_STATUS_INFO_get0_failure_info(a) ((a)->failure_info)
#endif

#if !defined(HAVE_TS_VERIFY_CTS_SET_CERTS)
#if !defined(HAVE_TS_VERIFY_CTS_SET_CERTS) && !defined(HAVE_TS_VERIFY_CTX_SET_CERTS)
# define TS_VERIFY_CTS_set_certs(ctx, crts) ((ctx)->certs=(crts))
#endif

Expand All @@ -214,4 +221,10 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
} while (0)
#endif

#if !defined(HAVE_ERR_GET_ERROR_ALL)
# define ERR_get_error_all(file, line, func, data, flags) ERR_get_error_line_data(file, line, data, flags)
#endif



#endif /* _OSSL_OPENSSL_MISSING_H_ */
4 changes: 2 additions & 2 deletions ext/openssl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ ossl_clear_error(void)
{
if (dOSSL == Qtrue) {
unsigned long e;
const char *file, *data, *errstr;
const char *file, *data, *errstr, *func;
int line, flags;

while ((e = ERR_get_error_line_data(&file, &line, &data, &flags))) {
while ((e = ERR_get_error_all(&file, &line, &func, &data, &flags))) {
errstr = ERR_error_string(e, NULL);
if (!errstr)
errstr = "(null)";
Expand Down
6 changes: 5 additions & 1 deletion ext/openssl/ossl_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ ossl_pkey_check_public_key(const EVP_PKEY *pkey)

/* OpenSSL < 1.1.0 takes non-const pointer */
ptr = EVP_PKEY_get0((EVP_PKEY *)pkey);
if(ptr == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pardon this style note: Other if statements are following by a space character in this file. I don't know the preferred form, just noted this being slightly different from the other if conditionals.

ossl_raise(ePKeyError, "public key NULL");
return;
}
switch (EVP_PKEY_base_id(pkey)) {
case EVP_PKEY_RSA:
RSA_get0_key(ptr, &n, &e, NULL);
Expand Down Expand Up @@ -926,8 +930,8 @@ ossl_pkey_verify(int argc, VALUE *argv, VALUE self)
int state, ret;

GetPKey(self, pkey);
rb_scan_args(argc, argv, "31", &digest, &sig, &data, &options);
ossl_pkey_check_public_key(pkey);
rb_scan_args(argc, argv, "31", &digest, &sig, &data, &options);
if (!NIL_P(digest))
md = ossl_evp_get_digestbyname(digest);
StringValue(sig);
Expand Down