Skip to content

Commit 3269dd3

Browse files
orgadsmetaskills
authored andcommitted
OpenSSL v1.1.0. Fixes #347 #344 #310 #290 #349 #323 #330
* 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
1 parent 0b8b7dc commit 3269dd3

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.diff eol=lf

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Rake::ExtensionTask.new('tiny_tds', gemspec) do |ext|
6868
gemplat = spec.platform.to_s
6969
host = platform_host_map[gemplat]
7070
dlls = [
71-
"libeay32-#{OPENSSL_VERSION}-#{host}.dll",
72-
"ssleay32-#{OPENSSL_VERSION}-#{host}.dll",
71+
"libcrypto32-#{OPENSSL_VERSION}-#{host}.dll",
72+
"libssl32-#{OPENSSL_VERSION}-#{host}.dll",
7373
'libiconv-2.dll',
7474
'libsybdb-5.dll'
7575
]

ext/tiny_tds/extconf.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ def extract_file(file, target)
151151
end
152152
end
153153

154+
def execute(action, command, options={})
155+
prev_path = ENV['PATH']
156+
if host=~/mingw/
157+
git_perl = 'C:/Program Files/Git/usr/bin'
158+
if File.directory?(git_perl)
159+
ENV['PATH'] = git_perl + ';' + ENV['PATH']
160+
ENV['PERL'] = 'perl'
161+
end
162+
end
163+
super
164+
ENV['PATH'] = prev_path
165+
end
166+
154167
def configure
155168
config = if host=~/mingw/
156169
host=~/x86_64/ ? 'mingw64' : 'mingw'
@@ -181,20 +194,20 @@ def dllwrap(dllname, outputlib, deffile, linkto)
181194

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

194207
def install
195208
super
196-
FileUtils.cp "#{work_path}/libeay32-#{version}-#{host}.dll", "#{path}/bin/"
197-
FileUtils.cp "#{work_path}/ssleay32-#{version}-#{host}.dll", "#{path}/bin/"
209+
FileUtils.cp "#{work_path}/libcrypto32-#{version}-#{host}.dll", "#{path}/bin/"
210+
FileUtils.cp "#{work_path}/libssl32-#{version}-#{host}.dll", "#{path}/bin/"
198211
FileUtils.cp "#{work_path}/libcrypto.dll.a", "#{path}/lib/"
199212
FileUtils.cp "#{work_path}/libssl.dll.a", "#{path}/lib/"
200213
end

ext/tiny_tds/extconsts.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.14"
33
ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
44

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

8-
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.21"
8+
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.27"
99
FREETDS_VERSION_INFO = Hash.new { |h,k|
1010
h[k] = {files: "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.bz2"}
1111
}

ports/patches/freetds/1.00.21/0001-mingw_missing_inet_pton.diff renamed to ports/patches/freetds/1.00.27/0001-mingw_missing_inet_pton.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
diff --git a/src/tds/tls.c b/src/tds/tls.c
2-
index 0d11a33..b8ab2ba 100644
2+
index 09e7fa0..1da18f6 100644
33
--- a/src/tds/tls.c
44
+++ b/src/tds/tls.c
5-
@@ -72,6 +72,29 @@
6-
#define SSL_PTR bio->ptr
5+
@@ -101,6 +101,29 @@
6+
#define SSL_PTR BIO_get_data(bio)
77
#endif
88

99
+/*
1010
+ * Add a workaround for older Mingw versions without inet_pton().
1111
+ * This means RubyInstallers DevKit-4.7.2 in particular.
1212
+ */
13-
+#if defined(__MINGW64_VERSION_MAJOR) && !defined(InetPtonA)
13+
+#if defined(__MINGW32__) && !defined(InetPtonA)
1414
+ #include <windows.h>
1515
+
1616
+ static HMODULE ws2_32 = NULL;

test/bin/install-openssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010
wget https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
1111
tar -xzf openssl-$OPENSSL_VERSION.tar.gz
1212
cd openssl-$OPENSSL_VERSION
13-
./config --prefix=/opt/local
13+
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
1414
make
1515
make install
1616
cd ..

0 commit comments

Comments
 (0)