Skip to content

Instantly share code, notes, and snippets.

@kriansa
Last active April 14, 2020 12:26
Show Gist options
  • Save kriansa/dd1b9a0d8dfec776fc91 to your computer and use it in GitHub Desktop.
Save kriansa/dd1b9a0d8dfec776fc91 to your computer and use it in GitHub Desktop.
Source patch to add support to TLS 1.1 and 1.2 to Ruby 1.9.3 - https://garajau.com.br/2015/07/tls-1-1-and-1-2-support-for-ruby-1-9-3
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -107,6 +107,18 @@
OSSL_SSL_METHOD_ENTRY(TLSv1),
OSSL_SSL_METHOD_ENTRY(TLSv1_server),
OSSL_SSL_METHOD_ENTRY(TLSv1_client),
+#if defined(HAVE_TLSV1_2_METHOD) && defined(HAVE_TLSV1_2_SERVER_METHOD) && \
+ defined(HAVE_TLSV1_2_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2_client),
+#endif
+#if defined(HAVE_TLSV1_1_METHOD) && defined(HAVE_TLSV1_1_SERVER_METHOD) && \
+ defined(HAVE_TLSV1_1_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1_client),
+#endif
#if defined(HAVE_SSLV2_METHOD) && defined(HAVE_SSLV2_SERVER_METHOD) && \
defined(HAVE_SSLV2_CLIENT_METHOD)
OSSL_SSL_METHOD_ENTRY(SSLv2),
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -104,6 +104,12 @@
have_func("SSLv2_method")
have_func("SSLv2_server_method")
have_func("SSLv2_client_method")
+have_func("TLSv1_1_method")
+have_func("TLSv1_1_server_method")
+have_func("TLSv1_1_client_method")
+have_func("TLSv1_2_method")
+have_func("TLSv1_2_server_method")
+have_func("TLSv1_2_client_method")
unless have_func("SSL_set_tlsext_host_name", ['openssl/ssl.h'])
have_macro("SSL_set_tlsext_host_name", ['openssl/ssl.h']) && $defs.push("-DHAVE_SSL_SET_TLSEXT_HOST_NAME")
end
@anmishra
Copy link

@kriansa How can I inject this patch & recompile my ruby-1.9.3 without using RVM?
@supratikdebnath @jiroycho @birajchoudhury

@kriansa
Copy link
Author

kriansa commented Mar 5, 2016

@anmishra You can follow the rvm steps here: https://rvm.io/rubies/patching
In short, rvm install 1.9 --patch https://gist.githubusercontent.com/kriansa/dd1b9a0d8dfec776fc91/raw/9ec47e3297da712e3acb06b86288ea36c863133c/openssl_tls_1.2.patch should do it.

edit:

See my answer below to see how to inject this patch without RVM.

@variousred
Copy link

How can I inject this patch and recompile ruby 1.9.3 WITHOUT using RVM?

@kriansa
Copy link
Author

kriansa commented Nov 18, 2017

@variousred
I suggest that you use ruby-build. See here the instructions to install a Ruby version using a patch. If you still want to compile it manually, download the tar.gz source and apply the patch manually by using the patch command, then proceed with the compilation.

@anmishra
Sorry that I misread your question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment