user10587656
user10587656

Reputation:

Perl ODBC SSL connection to MSSQL

I use the following to connect an application (client on Windows) to a remote MSSQL database:

use DBD::ODBC;
$dbh = DBI->connect(
   "dbi:ODBC:Driver={SQL Server};
    Server=$SQLservice;UID=$SQLuser;PWD=$SQLpassword", 
    {PrintError => 0, RaiseError => 1, AutoCommit => $AutoCommit, FetchHashKeyName => 'NAME_lc'}
) or die "Can't connect to the database: $DBI::errstr\n";

Now my company asks if it is possible for the clients to use SQL Server 2017 with SSL. DBD::ODBC doesn't mention SSL at all, and I have not found any information on the internet (not to say details instrctions on how to realize it). Does it mean, I should answer "no"?

Upvotes: 0

Views: 772

Answers (1)

Andrey Nikolov
Andrey Nikolov

Reputation: 13460

I believe the best solution for your case will be to force encrypted connection on the SQL Server itself. To do this on the server open SQL Server Configuration Manager, in SQL Server Network Configuration right click Protocols for your server and click Properties. On the Certificate tab, select the desired certificate from the drop-down for the Certificate box, and on the Flags tab, in the Force Encryption box, select Yes. Restart the SQL Server service.

enter image description here

Of course, in this case you will need to setup certificates. For detailed information you can see Microsoft's article Enable Encrypted Connections to the Database Engine.

Upvotes: 2

Related Questions