Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: DBI connecting to MS SQL Server TLS 1.2

by soonix (Canon)
on Sep 29, 2019 at 17:49 UTC ( [id://11106842]=note: print w/replies, xml ) Need Help??


in reply to DBI connecting to MS SQL Server TLS 1.2

I'm not currently at work, so can't test. My suggestions:
  • I don't put the user name and password in the connection string, my connect statement looks like
    my $dbh = DBI->connect("dbi:ODBC:DRIVER=SQL Server;SERVER=HOST\\INSTAN +CE;DATABASE=DBNAME", $DBUser, $PW) or die $DBI::errstr;
    (the actual connection string including the (single) backslash comes from a config file, but that shouldn't matter)
  • Did you test the exact same ODBC connection with another tool, e.g. MS QUERY/Excel/Access?
  • Do you use 32bit or 64bit Perl?

Replies are listed 'Best First'.
Re^2: DBI connecting to MS SQL Server TLS 1.2
by PearlNovice (Initiate) on Sep 29, 2019 at 23:12 UTC
    Thank you for your suggestion. No, the connection string used with other tools (e.g. Microsoft ssms) are slightly different. With other tools connection string specify all the details. Here I'm using Windows ODBC to define the DSN and pass in the DSN name via the DSN= parameter. I did this because I came across another article somewhere, where someone else had run into problem with SSL / TLS and he ended up defining an ODBC DSN, then passing both the DSN as well as the server name. I use 64bit Perl. Having said that I've figured out what my problem is now. Even though I upgraded my ODBC driver and defined my new DSN based on the new ODBC driver (which supports TLS1.2) my driver specification was still wrong like this:
    "dbi:ODBC:Driver={SQL Server}"
    I mistakenly assumed that the "dbi:ODBC:Driver={SQL Server}" is generic and defined somewhere within DBI. However having searched the DBI::ODBC package and not able to see where the driver is specified I thought maybe I need to specify the exact driver name as appeared under the list of drivers in the Windows ODBC applet, and that fixed it. So my updated code is like this (and it works now):
    "dbi:ODBC:Driver={ODBC Driver 17 for SQL Server}"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11106842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found