diff --git a/Rakefile b/Rakefile index ab708bd22..2871b1f86 100644 --- a/Rakefile +++ b/Rakefile @@ -38,7 +38,17 @@ task :debug_compiler do end task :debug do - ruby "-I./lib -ropenssl -ve'puts OpenSSL::OPENSSL_VERSION, OpenSSL::OPENSSL_LIBRARY_VERSION'" + ruby_code = <<~'EOF' + libre_version_number_str = (!OpenSSL::LIBRESSL_VERSION_NUMBER.nil?) ? + OpenSSL::LIBRESSL_VERSION_NUMBER.to_s(16) : "nil" + puts <<~'MESSAGE' + OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION} + OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION} + OpenSSL::OPENSSL_VERSION_NUMBER: #{OpenSSL::OPENSSL_VERSION_NUMBER.to_s(16)} + OpenSSL::LIBRESSL_VERSION_NUMBER: #{libre_version_number_str} + MESSAGE + EOF + ruby %Q(-I./lib -ropenssl -ve'#{ruby_code}') end task :default => :test diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index e67832d46..ac0f106d5 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -1150,9 +1150,29 @@ Init_openssl(void) /* * Version number of OpenSSL the ruby OpenSSL extension was built with * (base 16) + * + * OpenSSL 3: 0xMNN00PP0 (major minor 00 patch 0) + * OpenSSL 1: 0xMNNFFPPS (major minor fix patch status) + * LibreSSL : 0x20000000 (fixed value) + * + * See also the man page OPENSSL_VERSION_NUMBER(3). */ rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER)); + /* + * Version number of LibreSSL the ruby OpenSSL extension was built with + * (base 16) + * + * LibreSSL: 0xMNNFFPPS (major minor fix patch status) + * + * See also the man page OPENSSL_VERSION_NUMBER(3). + */ +#if defined(LIBRESSL_VERSION_NUMBER) + rb_define_const(mOSSL, "LIBRESSL_VERSION_NUMBER", INT2NUM(LIBRESSL_VERSION_NUMBER)); +#else + rb_define_const(mOSSL, "LIBRESSL_VERSION_NUMBER", Qnil); +#endif + /* * Boolean indicating whether OpenSSL is FIPS-capable or not */