rubyopensslrvmpuma

Unable to install puma on macOS 12 due to SSL error


I am running into the following error when trying to bundle install the puma gem. Ruby is installed with rvm (1.29.12-next). I believe the issue has something to do with openSSL, but i have no idea how exactly. I have openSSL installed via homebrew.

The only other similar question i've found was this one but the only suggestion there is to try a newer version of Ruby; this isn't an option for me as I specifically need 3.0.6 to be compatible on Heroku's heroku-20 platform

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.                                                                                                                                                                                                                                                   [0/383]
                                                                               
current directory: /Users/tony/.rvm/gems/ruby-3.0.6/gems/puma-6.3.0/ext/puma_http11                                                                       
/Users/tony/.rvm/rubies/ruby-3.0.6/bin/ruby -I /Users/tony/.rvm/rubies/ruby-3.0.6/lib/ruby/3.0.0 -r ./siteconf20230713-8369-4of5qc.rb extconf.rb              
checking for BIO_read() in -llibcrypto... no
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes 
checking for DTLS_method() in openssl/ssl.h... no
checking for SSL_CTX_set_session_cache_mode(NULL, 0) in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... no
checking for SSL_CTX_set_min_proto_version(NULL, 0) in openssl/ssl.h... no
checking for X509_STORE_up_ref()... no
checking for SSL_CTX_set_ecdh_auto(NULL, 0) in openssl/ssl.h... no
checking for SSL_CTX_set_dh_auto(NULL, 0) in openssl/ssl.h... no
checking for SSL_get1_peer_certificate() in openssl/ssl.h... no
checking for Random.bytes... yes
creating Makefile            
                                                                               
current directory: /Users/tony/.rvm/gems/ruby-3.0.6/gems/puma-6.3.0/ext/puma_http11                                                                           
make DESTDIR\= clean    
                                                                               
current directory: /Users/tony/.rvm/gems/ruby-3.0.6/gems/puma-6.3.0/ext/puma_http11                                                                           
make DESTDIR\=                 
compiling http11_parser.c       
compiling mini_ssl.c      
mini_ssl.c:329:32: error: implicit declaration of function 'SSL_CTX_get0_param' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                   
    X509_VERIFY_PARAM *param = SSL_CTX_get0_param(ctx);
                               ^
mini_ssl.c:329:32: note: did you mean 'SSL_CTX_set1_param'?
/Users/tony/.rvm/usr//include/openssl/ssl.h:1824:5: note: 'SSL_CTX_set1_param' declared here                                                                  
int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);
    ^                           
mini_ssl.c:329:24: warning: incompatible integer to pointer conversion initializing 'X509_VERIFY_PARAM *' (aka 'struct X509_VERIFY_PARAM_st *') with an expression of type 'int' [-Wint-conversion]                                                                                                                         
    X509_VERIFY_PARAM *param = SSL_CTX_get0_param(ctx);
                       ^       ~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.    
make: *** [mini_ssl.o] Error 1                                    

make failed, exit code 2

Solution

  • Ruby 3.1 was the first version supporting OpenSSL 3 and there are no plans to back port OpenSSL 3 support to Ruby <=3.0.x. When you want to install a Ruby version prior to 3.1 (like 3.0.6 in your case) then you have to use OpenSSL 1.1.

    To fix your setup, I suggest the following steps:

    1. Uninstall all versions of OpenSSL

    2. Uninstall Ruby

    3. Reinstall OpenSSL@1.1 with

      brew install openssl@1.1
      
    4. Reinstall Ruby 3.0.6 with linking to OpenSSL 1.1 with:

      rvm install 3.0.6 --with-openssl-dir=$(brew --prefix openssl@1.1)