Skip to content

Commit

Permalink
OpenSSL v1.1.0. Fixes #347 #344 #310 #290 #349 #323 #330
Browse files Browse the repository at this point in the history
* Use OpenSSL v1.1.0e & FreeTDS v1.00.27 for Windows builds.
* Adapt dll names to 1.1.0 scheme
 - libeay -> libcrypto
 - ssleay -> libssl
* Use perl in Git installation for openssl
* OpenSSL Requires Perl >= 5.10, while the Ruby devkit uses MSYS1 with Perl 5.8.8. To overcome this, prepend Git's usr/bin to the PATH. It has MSYS2 with a recent version of perl.
* MinGW: Fix inet_pton also for 32-bit
  • Loading branch information
orgads authored and metaskills committed Mar 12, 2017
1 parent 0b8b7dc commit 3269dd3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.diff eol=lf
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Rake::ExtensionTask.new('tiny_tds', gemspec) do |ext|
gemplat = spec.platform.to_s
host = platform_host_map[gemplat]
dlls = [
"libeay32-#{OPENSSL_VERSION}-#{host}.dll",
"ssleay32-#{OPENSSL_VERSION}-#{host}.dll",
"libcrypto32-#{OPENSSL_VERSION}-#{host}.dll",
"libssl32-#{OPENSSL_VERSION}-#{host}.dll",
'libiconv-2.dll',
'libsybdb-5.dll'
]
Expand Down
27 changes: 20 additions & 7 deletions ext/tiny_tds/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ def extract_file(file, target)
end
end

def execute(action, command, options={})
prev_path = ENV['PATH']
if host=~/mingw/
git_perl = 'C:/Program Files/Git/usr/bin'
if File.directory?(git_perl)
ENV['PATH'] = git_perl + ';' + ENV['PATH']
ENV['PERL'] = 'perl'
end
end
super
ENV['PATH'] = prev_path
end

def configure
config = if host=~/mingw/
host=~/x86_64/ ? 'mingw64' : 'mingw'
Expand Down Expand Up @@ -181,20 +194,20 @@ def dllwrap(dllname, outputlib, deffile, linkto)

def compile
super
# OpenSSL DLLs are called "libeay32.dll" and "ssleay32.dll" per default,
# OpenSSL DLLs are called "libcrypto32.dll" and "libssl32.dll" per default,
# regardless to the version. This is best suited to meet the Windows DLL hell.
# To avoid any conflicts we do a static build and build DLLs afterwards,
# with our own naming scheme.
execute "mkdef-libeay32", "(perl util/mkdef.pl 32 libeay >libeay32.def)"
execute "mkdef-ssleay32", "(perl util/mkdef.pl 32 ssleay >ssleay32.def)"
dllwrap("libeay32-#{version}-#{host}", "libcrypto.dll.a", "libeay32.def", "libcrypto.a -lws2_32 -lgdi32 -lcrypt32")
dllwrap("ssleay32-#{version}-#{host}", "libssl.dll.a", "ssleay32.def", "libssl.a libcrypto.dll.a")
execute "mkdef-crypto32", "(perl util/mkdef.pl crypto 32 >libcrypto32.def)"
execute "mkdef-ssl32", "(perl util/mkdef.pl ssl 32 >libssl32.def)"
dllwrap("libcrypto32-#{version}-#{host}", "libcrypto.dll.a", "libcrypto32.def", "libcrypto.a -lws2_32 -lgdi32 -lcrypt32")
dllwrap("libssl32-#{version}-#{host}", "libssl.dll.a", "libssl32.def", "libssl.a libcrypto.dll.a")
end

def install
super
FileUtils.cp "#{work_path}/libeay32-#{version}-#{host}.dll", "#{path}/bin/"
FileUtils.cp "#{work_path}/ssleay32-#{version}-#{host}.dll", "#{path}/bin/"
FileUtils.cp "#{work_path}/libcrypto32-#{version}-#{host}.dll", "#{path}/bin/"
FileUtils.cp "#{work_path}/libssl32-#{version}-#{host}.dll", "#{path}/bin/"
FileUtils.cp "#{work_path}/libcrypto.dll.a", "#{path}/lib/"
FileUtils.cp "#{work_path}/libssl.dll.a", "#{path}/lib/"
end
Expand Down
4 changes: 2 additions & 2 deletions ext/tiny_tds/extconsts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.14"
ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"

OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.0.2j'
OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.1.0e'
OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"

FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.21"
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.27"
FREETDS_VERSION_INFO = Hash.new { |h,k|
h[k] = {files: "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.bz2"}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/src/tds/tls.c b/src/tds/tls.c
index 0d11a33..b8ab2ba 100644
index 09e7fa0..1da18f6 100644
--- a/src/tds/tls.c
+++ b/src/tds/tls.c
@@ -72,6 +72,29 @@
#define SSL_PTR bio->ptr
@@ -101,6 +101,29 @@
#define SSL_PTR BIO_get_data(bio)
#endif

+/*
+ * Add a workaround for older Mingw versions without inet_pton().
+ * This means RubyInstallers DevKit-4.7.2 in particular.
+ */
+#if defined(__MINGW64_VERSION_MAJOR) && !defined(InetPtonA)
+#if defined(__MINGW32__) && !defined(InetPtonA)
+ #include <windows.h>
+
+ static HMODULE ws2_32 = NULL;
Expand Down
2 changes: 1 addition & 1 deletion test/bin/install-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
wget https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xzf openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
./config --prefix=/opt/local
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
make
make install
cd ..
Expand Down

0 comments on commit 3269dd3

Please sign in to comment.