From f1df06294474186137a9d1e80e65cb14ec3a5c66 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Mon, 14 Aug 2023 16:02:42 +0200 Subject: [ruby/openssl] Enhance printing OpenSSL versions. * Updated the `OpenSSL::OPENSSL_VERSION_NUMBER` comment explaining the format. * Added the `OpenSSL::LIBRESSL_VERSION_NUMBER` to print LibreSSL version number, in the case that Ruby OpenSSL binding is compiled with LibreSSL. Note `test/openssl/utils.rb#libressl?` is not using this value in it for now. * Update `rake debug` to print the values in a readable way, adding `OpenSSL::OPENSSL_VERSION_NUMBER` and `OpenSSL::LIBRESSL_VERSION_NUMBER`. https://github.com/ruby/openssl/commit/d19e6360ed --- ext/openssl/ossl.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'ext/openssl/ossl.c') diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 0bd2fa497e..d27e56dca7 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -1152,10 +1152,27 @@ Init_openssl(void) /* * Version number of OpenSSL the ruby OpenSSL extension was built with - * (base 16) + * (base 16). The formats are below. + * + * [OpenSSL 3] 0xMNN00PP0 (major minor 00 patch 0) + * [OpenSSL before 3] 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)); +#if defined(LIBRESSL_VERSION_NUMBER) + /* + * Version number of LibreSSL the ruby OpenSSL extension was built with + * (base 16). The format is 0xMNNFFPPS (major minor fix patch + * status). This constant is only defined in LibreSSL cases. + * + * See also the man page OPENSSL_VERSION_NUMBER(3). + */ + rb_define_const(mOSSL, "LIBRESSL_VERSION_NUMBER", INT2NUM(LIBRESSL_VERSION_NUMBER)); +#endif + /* * Boolean indicating whether OpenSSL is FIPS-capable or not */ -- cgit v1.2.3