Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Last active April 17, 2024 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringsn88keys/fb80ad398406fabaeb040b7eb6eef0b1 to your computer and use it in GitHub Desktop.
Save stringsn88keys/fb80ad398406fabaeb040b7eb6eef0b1 to your computer and use it in GitHub Desktop.
OpenSSL ruby constants and settings dump
require 'openssl'
# https://ruby.github.io/openssl/OpenSSL.html
puts "OpenSSL::OPENSSL_FIPS = #{OpenSSL::OPENSSL_FIPS}"
puts "\t-> Boolean indicating whether OpenSSL is FIPS-capable or not"
# try to turn on fips_mode if it is marked as true
if OpenSSL::OPENSSL_FIPS
puts "-> Setting fips_mode to true"
begin
OpenSSL.fips_mode = true
puts "-> fips_mode successfully turned on"
rescue OpenSSL::OpenSSLError => e
puts "X-> turning on fips_mode failed with \"#{e.message}\""
end
end
puts
puts "OpenSSL::OPENSSL_LIBRARY_VERSION = #{OpenSSL::OPENSSL_LIBRARY_VERSION}"
puts "OpenSSL::OPENSSL_VERSION = #{OpenSSL::OPENSSL_VERSION}"
puts "-> Version of OpenSSL the ruby OpenSSL extension was built with"
puts
puts "OpenSSL::OPENSSL_VERSION_NUMBER = #{OpenSSL::OPENSSL_VERSION_NUMBER.to_s(16)}"
puts "-> Version number of OpenSSL the ruby OpenSSL extension was built with (base 16)."
puts
puts " The formats are below."
puts " ----------------------"
puts " OpenSSL 3"
puts " ->0xMNN00PP0 (major minor 00 patch 0)"
puts " OpenSSL before 3"
puts " ->0xMNNFFPPS (major minor fix patch status)"
puts " LibreSSL"
puts " -> 0x20000000 (fixed value)"
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment