Bug 218454 - databases/freetds: cannot connect to MS SQL Server 2008 after upgrade to 1.00.27,1
Summary: databases/freetds: cannot connect to MS SQL Server 2008 after upgrade to 1.00...
Status: Closed Feedback Timeout
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Muhammad Moinur Rahman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-07 08:56 UTC by Miroslav Lachman
Modified: 2022-05-23 06:27 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (bofh)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miroslav Lachman 2017-04-07 08:56:58 UTC
databases/freetds and php56-mssql worked for us for many years but it failed after last upgrade to freetds-1.00.27,1. Previous version (freetds-1.00.1,1) works fine.

# tsql -S MSSQLsrv -p 1433 -D JBDATA -U user -P pass
locale is "C"
locale charset is "US-ASCII"
using default charset "cp1250"
Setting JBDATA as default database in login packet
Error 20017 (severity 9):
        Unexpected EOF from the server
Error 20002 (severity 9):
        Adaptive Server connection failed
There was a problem connecting to the server


; freetds.conf
[MSSQLsrv]
        host = 10.20.30.40
        port = 1433
        tds version = 8.0
        client charset = cp1250


The failing connection is to Windows Server 2003 R2 SP2 / MS SQL Server 2008

Connection to other machine with Windows Server 2012 R2 / MS SQL Server 2014 works fine.

freetds was build on our poudriere machine 10.3 amd64. 

Info about resulting package

pkg info freetds-1.00.27,1
freetds-1.00.27,1
Name           : freetds
Version        : 1.00.27,1
Installed on   : Fri Mar 31 15:03:53 2017 CEST
Origin         : databases/freetds
Architecture   : FreeBSD:10:amd64
Prefix         : /usr/local
Categories     : databases
Licenses       : GPLv2
Maintainer     : bofh@FreeBSD.org
WWW            : http://www.freetds.org/
Comment        : Sybase/Microsoft TDS protocol library
Options        :
        DOCS           : off
        GNUTLS         : off
        IODBC          : off
        MARS           : off
        OPENSSL        : on
        UNIXODBC       : on
Shared Libs required:
        libcrypto.so.9
        libodbc.so.2
        libodbcinst.so.2
        libssl.so.9
        libgcrypt.so.20
Shared Libs provided:
        libtdsodbc.so.0
        libsybdb.so.5
        libct.so.4

I don't know how to fix it. 
Please let me know I you need some more details.
Comment 1 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2017-04-07 09:16:44 UTC
So far I know that freetds doesn't support tds of more than 7.4.
Comment 2 Miroslav Lachman 2017-04-07 12:08:38 UTC
I don't know what tds version is supported or not, I only know that with this freetds.conf entry it was working for years and it is working for another MSSQL server but stopped working for one I mentioned after upgrade.
If I downgraded to freetds-1.00.1 without changing anything in freetds.conf it works again. But not with freetds-1.00.27 no matter what I tried in freetds.conf.
Comment 3 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2017-04-08 13:00:05 UTC
Can you enable dump file in freetds.conf and share the same?
Comment 4 Miroslav Lachman 2017-04-10 08:25:30 UTC
Here is the dump

log.c:167:Starting log file for FreeTDS 1.00.27
        on 2017-04-10 10:22:24 with debug flags 0x4fff.
iconv.c:325:tds_iconv_open(0x80241f180, cp1250)
iconv.c:185:local name for ISO-8859-1 is ISO-8859-1
iconv.c:185:local name for UTF-8 is UTF-8
iconv.c:185:local name for UCS-2LE is UCS-2LE
iconv.c:185:local name for UCS-2BE is UCS-2BE
iconv.c:343:setting up conversions for client charset "cp1250"
iconv.c:345:preparing iconv for "cp1250" <-> "UCS-2LE" conversion
iconv.c:384:tds_iconv_open: done
net.c:216:Connecting to 11.22.33.44 port 1433 (TDS version 7.4)
net.c:242:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:343:tds_open_socket() succeeded
packet.c:741:Sending packet
0000 12 01 00 3a 00 00 00 00-00 00 1a 00 06 01 00 20 |...:.... ....... |
0010 00 01 02 00 21 00 0c 03-00 2d 00 04 04 00 31 00 |....!... .-....1.|
0020 01 ff 09 00 00 00 00 00-00 4d 53 53 51 4c 53 65 |........ .MSSQLSe|
0030 72 76 65 72 00 f8 63 01-00 00                   |rver..c. ..|

packet.c:639:Received packet
0000 04 01 00 2b 00 00 01 00-00 00 1a 00 06 01 00 20 |...+.... ....... |
0010 00 01 02 00 21 00 01 03-00 22 00 00 04 00 22 00 |....!... ."....".|
0020 01 ff 0a 00 15 7c 00 00-00 00 00                |.....|.. ...|

login.c:1185:detected flag 0
tls.c:938:setting default openssl cipher to:HIGH:!SSLv2:!aNULL:-DH
tls.c:144:in tds_push_func_login
tls.c:114:in tds_pull_func_login
packet.c:741:Sending packet
0000 12 01 00 85 00 00 00 00-16 03 01 00 78 01 00 00 |........ ....x...|
0010 74 03 01 c3 e3 d9 e3 0a-f1 82 ea fb 0a aa a5 f8 |t....... ........|
0020 2f 8c 05 f6 87 13 15 92-6c ab 49 de 7a e3 ca d0 |/....... l.I.z...|
0030 77 c8 a2 00 00 1a c0 14-c0 0a c0 0f c0 05 00 35 |w....... .......5|
0040 00 84 c0 13 c0 09 c0 0e-c0 04 00 2f 00 41 00 ff |........ .../.A..|
0050 01 00 00 31 00 0b 00 04-03 00 01 02 00 0a 00 1c |...1.... ........|
0060 00 1a 00 17 00 19 00 1c-00 1b 00 18 00 1a 00 16 |........ ........|
0070 00 0e 00 0d 00 0b 00 0c-00 09 00 0a 00 23 00 00 |........ .....#..|
0080 00 0f 00 01 01         -                        |.....|

util.c:165:Changed query state from IDLE to DEAD
util.c:322:tdserror(0x80241d040, 0x80241f180, 20017, 0)
util.c:352:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
tls.c:985:handshake failed
login.c:530:login packet rejected
util.c:322:tdserror(0x80241d040, 0x80241f180, 20002, 0)
util.c:352:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:375:tdserror: returning TDS_INT_CANCEL(2)
mem.c:644:tds_free_all_results()
Comment 5 Miroslav Lachman 2017-05-19 09:34:06 UTC
I created ticket on GitHup https://github.com/FreeTDS/freetds/issues/118

It seems there is problem with OpenSSL. If I built FreeTDS with GnuTLS instead of OpenSSL then connection works again.
It is not a solution but workaround.

(or disable ecryption by "tds version = 7.0")
Comment 6 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2017-05-19 11:54:10 UTC
(In reply to Miroslav Lachman from comment #5)
Recently I have updated freetds stable to 1.00.38. Can you check please check it out and let me know?
Comment 7 Miroslav Lachman 2017-05-19 13:46:51 UTC
As I wrote on GitHub I already tried 38, 131 and 162. All with no luck. The only possible workarounds are tds version = 7.0 or GnuTLS.
OpenSSL doesn't work with FreeTDS versions newer than 1.00.1
Comment 8 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2017-05-22 11:22:21 UTC
Have been updated 1.00.39. Can you confirm the current status?