17

In SQL Server I can "Force Encryption" in protocols settings. If I leave that set to "No" any client can still require encryption.

Can I somehow see what connections to the database are using encryption?

SharpC
  • 145
  • 4
Mathias Rönnlund
  • 285
  • 1
  • 2
  • 7

4 Answers4

24

From TechNet sys.dm_exec_connections DMV: the encrypt_option will display FALSE if the connection is not encrypted.

Here is an example TSQL statement that can be run by administrators (VIEW SERVER STATE is the required privilege):

SELECT session_id, connect_time, net_transport, encrypt_option, auth_scheme, client_net_address 
FROM sys.dm_exec_connections
Mike
  • 648
  • 4
  • 13
Travis Page
  • 656
  • 5
  • 7
  • By default, this does not work for non-sysadmins. Accessing the dm_exec_connections view requires VIEW SERVER STATE permission on the server, which is not granted by default. Do you know of an alternative, which by default, all logins can access ? – William Jan 25 '17 at 16:01
  • 2
    why would a non 'VIEW SERVER STATE' user have any business checking whether connections are encrypted? – Mitch Wheat Oct 01 '18 at 16:42
  • 1
    @MitchWheat The same reason you, a 'standard user', can see the padlock icon up top in your browser right now - to know that their connection is encrypted. Users must not need administrator privileges to ensure encryption is being used. tldr: for security – Ian Boyd Apr 04 '21 at 23:58
  • If a standard user (I would say a client application) want a encrypted connection. It has to use/check the dedicated key (Encrypt=True) in the connexion string ! – Marco Guignard May 19 '21 at 10:08
5

There are various methods to check the connections :

  1. You can use a third party tool like Wireshark which lets you see what's happening on your network at a microscopic level and will help you in getting those encrypted connections.

  2. You can also use the Microsoft Network Monitor 3.4 to get those connection details.

  3. And as mentioned by travis you can also look at encrypt_option column of the sys.dm_exec_connections DMV

In addition please read the article which will help you understand more on this Encrypting connections in SQL Server 2005 & SQL Native Client with SS

Tony Hinkle
  • 7,939
  • 1
  • 21
  • 46
KASQLDBA
  • 7,159
  • 6
  • 27
  • 53
3

Please note that in SQL Server Management Studio (SSMS) the "View connection properties" does not show if the connection is Encrypted. It only shown if the client (SSMS) has asked for the connection to be encrypted.

enter image description here

If you are using Force Encryption = true on the server configuration all connections will be encrypted, but SSMS will not indicate it.

You can validate the connection on the server with:

SELECT encrypt_option,* FROM sys.dm_exec_connections

encrypt_option will be true for encrypted connections

enter image description here

Henrik Høyer
  • 179
  • 1
  • 6
2

You can also check whether the connection in encrypted in the SSMS, when you connect to a server with encryption, you will see a lock icon next to the server name in the bottom panel: encrypted connection SSMS

Without encryption, there is only server name without lock icon.