summaryrefslogtreecommitdiff
path: root/ext/openssl/extconf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/extconf.rb')
-rw-r--r--ext/openssl/extconf.rb137
1 files changed, 65 insertions, 72 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index bc3e4d3a21..1f32980940 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -8,26 +8,43 @@
= Licence
This program is licensed under the same licence as Ruby.
- (See the file 'LICENCE'.)
+ (See the file 'COPYING'.)
=end
require "mkmf"
-dir_config_given = dir_config("openssl").any?
-dir_config("kerberos")
+ssl_dirs = dir_config("openssl")
+dir_config_given = ssl_dirs.any?
+
+_, ssl_ldir = ssl_dirs
+if ssl_ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
+ # According to the `mkmf.rb#dir_config`, the `--with-openssl-dir=<dir>` uses
+ # the value of the `File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])` as a
+ # loaded library directory name.
+ ruby_ldir_name = File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])
+
+ raise "OpenSSL library directory could not be found in '#{ssl_ldir}'. " \
+ "You might want to fix this error in one of the following ways.\n" \
+ " * Recompile OpenSSL by configuring it with --libdir=#{ruby_ldir_name} " \
+ " to specify the OpenSSL library directory.\n" \
+ " * Recompile Ruby by configuring it with --libdir=<dir> to specify the " \
+ "Ruby library directory.\n" \
+ " * Compile this openssl gem with --with-openssl-include=<dir> and " \
+ "--with-openssl-lib=<dir> options to specify the OpenSSL include and " \
+ "library directories."
+end
Logging::message "=== OpenSSL for Ruby configurator ===\n"
-##
-# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
-# To turn it on, use: --with-debug or --enable-debug
-#
-if with_config("debug") or enable_config("debug")
- $defs.push("-DOSSL_DEBUG")
-end
$defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")
-have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h") # Ruby 3.1
+# Missing in TruffleRuby
+have_func("rb_call_super_kw(0, NULL, 0)", "ruby.h")
+# Ruby 3.1
+have_func("rb_io_descriptor", "ruby/io.h")
+have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h")
+# Ruby 3.2
+have_func("rb_io_timeout", "ruby/io.h")
Logging::message "=== Checking for system dependent stuff... ===\n"
have_library("nsl", "t_open")
@@ -45,7 +62,6 @@ end
def find_openssl_library
if $mswin || $mingw
# required for static OpenSSL libraries
- have_library("gdi32") # OpenSSL <= 1.0.2 (for RAND_screen())
have_library("crypt32")
end
@@ -62,12 +78,6 @@ def find_openssl_library
return true
end
- # OpenSSL <= 1.0.2: libeay32.lib and ssleay32.lib.
- if have_library("libeay32", "CRYPTO_malloc") &&
- have_library("ssleay32", "SSL_new")
- return true
- end
-
# LibreSSL: libcrypto-##.lib and libssl-##.lib, where ## is the ABI version
# number. We have to find the version number out by scanning libpath.
libpath = $LIBPATH.dup
@@ -105,14 +115,15 @@ end
version_ok = if have_macro("LIBRESSL_VERSION_NUMBER", "openssl/opensslv.h")
is_libressl = true
- checking_for("LibreSSL version >= 3.1.0") {
- try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30100000L", "openssl/opensslv.h") }
+ checking_for("LibreSSL version >= 3.9.0") {
+ try_static_assert("LIBRESSL_VERSION_NUMBER >= 0x30900000L", "openssl/opensslv.h") }
else
- checking_for("OpenSSL version >= 1.0.2") {
- try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10002000L", "openssl/opensslv.h") }
+ is_openssl = true
+ checking_for("OpenSSL version >= 1.1.1") {
+ try_static_assert("OPENSSL_VERSION_NUMBER >= 0x10101000L", "openssl/opensslv.h") }
end
unless version_ok
- raise "OpenSSL >= 1.0.2 or LibreSSL >= 3.1.0 is required"
+ raise "OpenSSL >= 1.1.1 or LibreSSL >= 3.9.0 is required"
end
# Prevent wincrypt.h from being included, which defines conflicting macro with openssl/x509.h
@@ -122,66 +133,30 @@ end
Logging::message "=== Checking for OpenSSL features... ===\n"
evp_h = "openssl/evp.h".freeze
-x509_h = "openssl/x509.h".freeze
ts_h = "openssl/ts.h".freeze
ssl_h = "openssl/ssl.h".freeze
+stack_h = "openssl/stack.h".freeze
# compile options
have_func("RAND_egd()", "openssl/rand.h")
-engines = %w{dynamic 4758cca aep atalla chil
- cswift nuron sureware ubsec padlock capi gmp gost cryptodev}
-engines.each { |name|
- have_func("ENGINE_load_#{name}()", "openssl/engine.h")
-}
-
-# added in 1.1.0
-if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
- $defs.push("-DHAVE_OPAQUE_OPENSSL")
-end
-have_func("EVP_MD_CTX_new()", evp_h)
-have_func("EVP_MD_CTX_free(NULL)", evp_h)
-have_func("EVP_MD_CTX_pkey_ctx(NULL)", evp_h)
-have_func("X509_STORE_get_ex_data(NULL, 0)", x509_h)
-have_func("X509_STORE_set_ex_data(NULL, 0, NULL)", x509_h)
-have_func("X509_STORE_get_ex_new_index(0, NULL, NULL, NULL, NULL)", x509_h)
-have_func("X509_CRL_get0_signature(NULL, NULL, NULL)", x509_h)
-have_func("X509_REQ_get0_signature(NULL, NULL, NULL)", x509_h)
-have_func("X509_REVOKED_get0_serialNumber(NULL)", x509_h)
-have_func("X509_REVOKED_get0_revocationDate(NULL)", x509_h)
-have_func("X509_get0_tbs_sigalg(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_untrusted(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_cert(NULL)", x509_h)
-have_func("X509_STORE_CTX_get0_chain(NULL)", x509_h)
-have_func("OCSP_SINGLERESP_get0_id(NULL)", "openssl/ocsp.h")
-have_func("SSL_CTX_get_ciphers(NULL)", ssl_h)
-have_func("X509_up_ref(NULL)", x509_h)
-have_func("X509_CRL_up_ref(NULL)", x509_h)
-have_func("X509_STORE_up_ref(NULL)", x509_h)
-have_func("SSL_SESSION_up_ref(NULL)", ssl_h)
-have_func("EVP_PKEY_up_ref(NULL)", evp_h)
-have_func("SSL_CTX_set_min_proto_version(NULL, 0)", ssl_h)
-have_func("SSL_CTX_get_security_level(NULL)", ssl_h)
-have_func("X509_get0_notBefore(NULL)", x509_h)
-have_func("SSL_SESSION_get_protocol_version(NULL)", ssl_h)
-have_func("TS_STATUS_INFO_get0_status(NULL)", ts_h)
-have_func("TS_STATUS_INFO_get0_text(NULL)", ts_h)
-have_func("TS_STATUS_INFO_get0_failure_info(NULL)", ts_h)
-have_func("TS_VERIFY_CTS_set_certs(NULL, NULL)", ts_h)
-have_func("TS_VERIFY_CTX_set_store(NULL, NULL)", ts_h)
-have_func("TS_VERIFY_CTX_add_flags(NULL, 0)", ts_h)
-have_func("TS_RESP_CTX_set_time_cb(NULL, NULL, NULL)", ts_h)
+
+# added in OpenSSL 1.0.2, not in LibreSSL yet
+have_func("SSL_CTX_set1_sigalgs_list(NULL, NULL)", ssl_h)
+# added in OpenSSL 1.0.2, not in LibreSSL or AWS-LC yet
+have_func("SSL_CTX_set1_client_sigalgs_list(NULL, NULL)", ssl_h)
+
+# added in 1.1.0, currently not in LibreSSL
have_func("EVP_PBE_scrypt(\"\", 0, (unsigned char *)\"\", 0, 0, 0, 0, 0, NULL, 0)", evp_h)
-have_func("SSL_CTX_set_post_handshake_auth(NULL, 0)", ssl_h)
-# added in 1.1.1
+# added in OpenSSL 1.1.1 and LibreSSL 3.5.0, then removed in LibreSSL 4.0.0
have_func("EVP_PKEY_check(NULL)", evp_h)
-have_func("EVP_PKEY_new_raw_private_key(0, NULL, (unsigned char *)\"\", 0)", evp_h)
-have_func("SSL_CTX_set_ciphersuites(NULL, \"\")", ssl_h)
+
+# added in OpenSSL 1.1.1, currently not in LibreSSL
+have_func("OPENSSL_sk_new_reserve(NULL, 0)", stack_h)
# added in 3.0.0
-have_func("SSL_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
+have_func("SSL_CTX_set0_tmp_dh_pkey(NULL, NULL)", ssl_h)
have_func("ERR_get_error_all(NULL, NULL, NULL, NULL, NULL)", "openssl/err.h")
-have_func("TS_VERIFY_CTX_set_certs(NULL, NULL)", ts_h)
have_func("SSL_CTX_load_verify_file(NULL, \"\")", ssl_h)
have_func("BN_check_prime(NULL, NULL, NULL)", "openssl/bn.h")
have_func("EVP_MD_CTX_get0_md(NULL)", evp_h)
@@ -189,8 +164,26 @@ have_func("EVP_MD_CTX_get_pkey_ctx(NULL)", evp_h)
have_func("EVP_PKEY_eq(NULL, NULL)", evp_h)
have_func("EVP_PKEY_dup(NULL)", evp_h)
+# added in 3.2.0
+have_func("SSL_get0_group_name(NULL)", ssl_h)
+
+# added in 3.4.0
+have_func("TS_VERIFY_CTX_set0_certs(NULL, NULL)", ts_h)
+
+# added in 3.5.0
+have_func("SSL_get0_peer_signature_name(NULL, NULL)", ssl_h)
+
+# added in 4.0.0
+have_func("ASN1_BIT_STRING_set1(NULL, NULL, 0, 0)", "openssl/asn1.h")
+
Logging::message "=== Checking done. ===\n"
+# Append flags from environment variables.
+extcflags = ENV["RUBY_OPENSSL_EXTCFLAGS"]
+append_cflags(extcflags.split) if extcflags
+extldflags = ENV["RUBY_OPENSSL_EXTLDFLAGS"]
+append_ldflags(extldflags.split) if extldflags
+
create_header
create_makefile("openssl")
Logging::message "Done.\n"