Repository: puma/puma
File: ext/puma_http11/extconf.rb (Ruby)

Code before:
    true
  elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
      %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
    true
  else
    puts '** Puma will be compiled without SSL support'
    false
  end

  if found_ssl
    have_header "openssl/bio.h"

    ssl_h = "openssl/ssl.h".freeze

    puts "\n──── Below are yes for 1.0.2 & later ────"
    have_func "DTLS_method"                            , ssl_h
    have_func "SSL_CTX_set_session_cache_mode(NULL, 0)", ssl_h
    have_func "SSL_CTX_set_ecdh_auto(NULL, 0)"         , ssl_h

    puts "\n──── Below are yes for 1.1.0 & later ────"
    have_func "TLS_server_method"                      , ssl_h
    have_func "SSL_CTX_set_min_proto_version(NULL, 0)" , ssl_h
    have_func "X509_STORE_up_ref"

    puts "\n──── Below is yes for 1.1.0 and later, but isn't documented until 3.0.0 ────"
    have_func "SSL_CTX_set_dh_auto(NULL, 0)"           , ssl_h

    puts "\n──── Below is yes for 1.1.1 & later ────"
    have_func "SSL_CTX_set_ciphersuites(NULL, \"\")"   , ssl_h

    puts "\n──── Below is yes for 3.0.0 & later ────"
    have_func "SSL_get1_peer_certificate"              , ssl_h

    puts ''

    # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
    if Random.respond_to?(:bytes)
      $defs.push "-DHAVE_RANDOM_BYTES"
      puts "checking for Random.bytes... yes"
    else
      puts "checking for Random.bytes... no"
    end
  end
end

if ENV["PUMA_MAKE_WARNINGS_INTO_ERRORS"]
  # Make all warnings into errors
  # Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
  if respond_to?(:append_cflags, true) # Ruby 2.5 and later
    append_cflags(config_string('WERRORFLAG') || '-Werror')
    append_cflags '-Wno-implicit-fallthrough'

Review comment (suggestion):
Should `X509_STORE_up_ref` be under 1.1.1? It moved here

https://www.openssl.org/docs/man1.1.0/man3/X509_STORE_up_ref.html is "Page Not Found" but https://www.openssl.org/docs/man1.1.1/man3/X509_STORE_up_ref.html exist

Code after:
    true
  elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
      %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
    true
  else
    puts '** Puma will be compiled without SSL support'
    false
  end

  if found_ssl
    have_header "openssl/bio.h"

    ssl_h = "openssl/ssl.h".freeze

    puts "\n──── Below are yes for 1.0.2 & later ────"
    have_func "DTLS_method"                            , ssl_h
    have_func "SSL_CTX_set_session_cache_mode(NULL, 0)", ssl_h

    puts "\n──── Below are yes for 1.1.0 & later ────"
    have_func "TLS_server_method"                      , ssl_h
    have_func "SSL_CTX_set_min_proto_version(NULL, 0)" , ssl_h

    puts "\n──── Below is yes for 1.1.0 and later, but isn't documented until 3.0.0 ────"
    # https://github.com/openssl/openssl/blob/OpenSSL_1_1_0/include/openssl/ssl.h#L1159
    have_func "SSL_CTX_set_dh_auto(NULL, 0)"           , ssl_h

    puts "\n──── Below is yes for 1.1.1 & later ────"
    have_func "SSL_CTX_set_ciphersuites(NULL, \"\")"   , ssl_h

    puts "\n──── Below is yes for 3.0.0 & later ────"
    have_func "SSL_get1_peer_certificate"              , ssl_h

    puts ''

    # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
    if Random.respond_to?(:bytes)
      $defs.push "-DHAVE_RANDOM_BYTES"
      puts "checking for Random.bytes... yes"
    else
      puts "checking for Random.bytes... no"
    end
  end
end

if ENV["PUMA_MAKE_WARNINGS_INTO_ERRORS"]
  # Make all warnings into errors
  # Except `implicit-fallthrough` since most failures comes from ragel state machine generated code
  if respond_to?(:append_cflags, true) # Ruby 2.5 and later
    append_cflags(config_string('WERRORFLAG') || '-Werror')
    append_cflags '-Wno-implicit-fallthrough'
  else