最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

odbc - FreeTDS TLS is not configured correctly for Sybase SQL Anywhere - Stack Overflow

programmeradmin4浏览0评论

I am trying to set up ODBC and FreeTDS to connect to a Sybase SQL Anywhere database server in the same network over TLS from an ubuntu:22.04 Docker image. It looks like it starts to communicate and we do get back the public key, but then the db sever responds with:

[WW012][unixODBC][FreeTDS][SQL Server]RAISERROR executed: TLS encryption is required for network database connections in NAMEOFDATABASEHERE 2.3.94.10 and later versions.
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

Here is my freetds.conf file:

[global]
# TDS protocol version - SQL Anywhere uses 5.0
tds version = 5.0
# Logging configuration
dump file = /tmp/freetds.log
dump file append = yes
debug flags = 0xffff
text size = 64512
client charset = UTF-8

[databasename]
# Server connection details
host = 23c8b.somedomainname
port = 2638    # Default SQL Anywhere port

# Protocol settings
tds version = 5.0

# Database name
ASA database = databasename
database = databasename

# TLS/Encryption settings
encryption = require
enable tls v1 = yes

# Debug settings
timeout = 60
connect timeout = 60

Here is my odbc.ini file.

[DnsName]
Driver = FreeTDS
Description = Some Company Database
# Using Server instead of Servername for ODBC-only config
Server = 23c8b.somedomainname
Port = 2638
Database = databasename
TDS_Version = 5.0
ClientCharset = UTF-8
Encryption = require
# Debug settings
DumpFile = /tmp/odbc.log
DumpFileAppend = Yes
DumpFlags = 0xffff

Here is my odbcinst.ini file:

[FreeTDS]
Description = FreeTDS Driver
Driver = /usr/lib/aarch64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/aarch64-linux-gnu/odbc/libtdsodbc.so
FileUsage = 1
UsageCount = 1

Here is the logs from FreeTDS:

00:57:13.106932 9 (log.c:187):Starting log file for FreeTDS 1.3.6
    on 2025-02-18 00:57:13 with debug flags 0xffff.
00:57:13.107029 9 (iconv.c:367):tds_iconv_open(0xaaaaffa74890, UTF-8)
00:57:13.107334 9 (iconv.c:198):local name for ISO-8859-1 is ISO-8859-1
00:57:13.107350 9 (iconv.c:198):local name for UTF-8 is UTF-8
00:57:13.107361 9 (iconv.c:198):local name for UCS-2LE is UCS-2LE
00:57:13.107369 9 (iconv.c:198):local name for UCS-2BE is UCS-2BE
00:57:13.107412 9 (iconv.c:389):setting up conversions for client charset "UTF-8"
00:57:13.107422 9 (iconv.c:391):preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
00:57:13.107593 9 (iconv.c:430):tds_iconv_open: done
00:57:13.107607 9 (net.c:391):Connecting with protocol version 5.0
00:57:13.107651 9 (net.c:318):Connecting to <I have omitted ip here> port 2638
00:57:13.107930 9 (net.c:340):tds_setup_socket: connect(2) returned "Operation now in 
progress"
00:57:13.119036 9 (net.c:528):tds_open_socket() succeeded
00:57:13.119077 9 (packet.c:852):Sending packet

<I have omitted raw data here>

00:57:13.119187 9 (packet.c:852):Sending packet

<I have omitted raw data here>

00:57:13.119253 9 (token.c:418):tds_process_login_tokens()
00:57:13.127345 9 (packet.c:410):Received packet

<I have omitted raw data here. We do get the public key from the server here.>

00:57:13.127496 9 (token.c:422):looking for login token, got  ad(LOGINACK)
00:57:13.127502 9 (token.c:348):server reports TDS version 5.0.0.0
00:57:13.127506 9 (token.c:350):Product name for 0x5000000 is unknown
00:57:13.127512 9 (token.c:384):Product version 11000000
00:57:13.127516 9 (token.c:422):looking for login token, got  65(MSG)
00:57:13.127520 9 (token.c:131):tds_process_default_tokens() marker is 65(MSG)
00:57:13.127524 9 (token.c:422):looking for login token, got  ec(TDS5_PARAMFMT)
00:57:13.127527 9 (token.c:131):tds_process_default_tokens() marker is 
ec(TDS5_PARAMFMT)
00:57:13.127538 9 (token.c:1651):tds_get_data_info(0xaaaaffa74c60, 0xaaaaffa89fa0, 1) 
[for parameter]
00:57:13.127543 9 (token.c:1713):processing result. type = 56(int), varint_size 0
00:57:13.127549 9 (token.c:1718):processing result. column_size 4
00:57:13.127552 9 (token.c:1651):tds_get_data_info(0xaaaaffa74c60, 0xaaaaffa8a060, 1) 
[for parameter]
00:57:13.127556 9 (token.c:1713):processing result. type = 225(longbinary), varint_size 5
00:57:13.127560 9 (token.c:1718):processing result. column_size 254
00:57:13.127563 9 (token.c:1651):tds_get_data_info(0xaaaaffa74c60, 0xaaaaffa8a120, 1) [for parameter]
00:57:13.127567 9 (token.c:1713):processing result. type = 225(longbinary), varint_size 5
00:57:13.127570 9 (token.c:1718):processing result. column_size 32
00:57:13.127574 9 (token.c:422):looking for login token, got  d7(TDS5_PARAMS)
00:57:13.127577 9 (token.c:131):tds_process_default_tokens() marker is d7(TDS5_PARAMS)
00:57:13.127581 9 (data.c:723):tds_get_data: type 56, varint size 0
00:57:13.127585 9 (data.c:767):tds_get_data(): wire column size is 4 
00:57:13.127588 9 (data.c:723):tds_get_data: type 225, varint size 5
00:57:13.127592 9 (data.c:767):tds_get_data(): wire column size is 254 
00:57:13.127596 9 (data.c:723):tds_get_data: type 225, varint size 5
00:57:13.127600 9 (data.c:767):tds_get_data(): wire column size is 32 
00:57:13.127603 9 (token.c:422):looking for login token, got  fd(DONE)
00:57:13.127606 9 (token.c:131):tds_process_default_tokens() marker is fd(DONE)
00:57:13.127610 9 (token.c:2100):tds_process_end: more_results = 0
       was_cancelled = 0
       error = 0
       done_count_valid = 0
00:57:13.127614 9 (token.c:2119):                rows_affected = 0
00:57:13.127617 9 (token.c:2122):tds_process_end() state set to TDS_IDLE
00:57:13.127773 9 (sec_negotiate_gnutls.h:266):em.db

<I have omitted raw data here>

00:57:13.127864 9 (sec_negotiate_gnutls.h:270):em.ros

<I have omitted raw data here>

00:57:13.127873 9 (sec_negotiate_gnutls.h:274):em.db

<I have omitted raw data here>

00:57:13.127894 9 (sec_negotiate_gnutls.h:278):em.ros

<I have omitted raw data here>

00:57:13.128010 9 (sec_negotiate_gnutls.h:356):em
    
<I have omitted raw data here>

00:57:13.128044 9 (packet.c:852):Sending packet

<I have omitted raw data here>

00:57:14.196075 9 (packet.c:410):Received packet

<I have omitted raw data here. This is where I get the error message above.>

00:57:14.196284 9 (token.c:422):looking for login token, got  ad(LOGINACK)
00:57:14.196299 9 (token.c:348):server reports TDS version 5.0.0.0
00:57:14.196309 9 (token.c:350):Product name for 0x5000000 is unknown
00:57:14.196325 9 (token.c:384):Product version 11000000
00:57:14.196334 9 (token.c:422):looking for login token, got  e5(EED)
00:57:14.196344 9 (token.c:131):tds_process_default_tokens() marker is e5(EED)
00:57:14.196354 9 (mem.c:656):tds_free_all_results()
00:57:14.196367 9 (token.c:2402):tds_process_info() reading message 28000 from server
00:57:14.196381 9 (token.c:2497):tds_process_info() calling client msg handler
00:57:14.196438 9 (token.c:2514):tds_process_info() returning TDS_SUCCESS
00:57:14.196453 9 (token.c:422):looking for login token, got  fd(DONE)
00:57:14.196477 9 (token.c:131):tds_process_default_tokens() marker is fd(DONE)
00:57:14.196487 9 (token.c:2100):tds_process_end: more_results = 0
       was_cancelled = 0
       error = 1
       done_count_valid = 0
00:57:14.196506 9 (token.c:2119):                rows_affected = 0
00:57:14.196523 9 (token.c:2122):tds_process_end() state set to TDS_IDLE
00:57:14.196534 9 (token.c:445):tds_process_login_tokens() returning TDS_FAIL
00:57:14.196543 9 (login.c:599):login packet accepted
00:57:14.196552 9 (query.c:3757):tds_disconnect() 
00:57:14.196562 9 (mem.c:656):tds_free_all_results()
00:57:14.196571 9 (util.c:179):Changed query state from IDLE to WRITING
00:57:14.196586 9 (packet.c:852):Sending packet

<I have omitted raw data here>

00:57:14.196836 9 (util.c:179):Changed query state from WRITING to PENDING
00:57:14.196859 9 (token.c:555):tds_process_tokens(0xaaaaffa74c60, 0xffffc1dd28c4, 
0xffffc1dd28c0, 0x100)
00:57:14.196869 9 (util.c:179):Changed query state from PENDING to READING
00:57:14.206072 9 (packet.c:410):Received packet

<I have omitted raw data here>

00:57:14.206103 9 (token.c:570):processing result tokens.  marker is  fd(DONE)
00:57:14.206111 9 (token.c:2100):tds_process_end: more_results = 0
       was_cancelled = 0
       error = 0
       done_count_valid = 0
00:57:14.206118 9 (token.c:2119):                rows_affected = 0
00:57:14.206124 9 (token.c:2122):tds_process_end() state set to TDS_IDLE
00:57:14.206132 9 (util.c:179):Changed query state from READING to IDLE
00:57:14.206138 9 (util.c:83):logic error: cannot change query state from IDLE to PENDING
00:57:14.206144 9 (util.c:179):Changed query state from IDLE to IDLE
00:57:14.206151 9 (token.c:555):tds_process_tokens(0xaaaaffa74c60, 0xffffc1dd28c4, 
0xffffc1dd28c0, 0x100)
00:57:14.206157 9 (token.c:558):tds_process_tokens() state is COMPLETED
00:57:14.206240 9 (util.c:179):Changed query state from IDLE to DEAD
00:57:14.206252 9 (util.c:333):tdserror(0xaaaae1fb0668, 0xaaaaffa74c60, 20002, 0)
00:57:14.206260 9 (util.c:369):tdserror: client library not called because either 
tds_ctx (0xaaaae1fb0668) or tds_ctx->err_handler is NULL
00:57:14.206267 9 (util.c:386):tdserror: returning TDS_INT_CANCEL(2)
00:57:14.206275 9 (mem.c:656):tds_free_all_results()

This is how we are starting the database. It is on a Windows server. Clients connect to it via Windows ODBC and the Windows Sybase driver.

Params are:

"Parameters"="-k -qi -qs -on 10m -o C:\\DB\\console.txt -ti240 -tl120 -gnh 500 -gl ALL -gd ALL -x tcpip(ServerPort=2636,2638) -xs HTTPS(PORT=2637;IDENTITY=c:\\BrandNameHere\\odbc.id;IDENTITY_PASSWORD=somepassword) -es -ec SIMPLE,TLS(IDENTITY=c:\\BrandNameHere\\odbc.id;IDENTITY_PASSWORD=somepassword) -n name C:\\DB\\databasename.db @c:\\BrandNameHere\\.tekey"

Thanks in advance for any input.

发布评论

评论列表(0)

  1. 暂无评论