I was connecting to Sql Server 2008 & 2008+ via Java program with
DriverManager.getConnection("jdbc:sqlserver://<Ip>;instance=MSSQLSERVER;domain=<domain>;IntegratedSecurity=true;ssl=request;", "administrator", "password");
I was able to connect successfully. However when I enabled Force encryption to true in the sql server via sql server configuration manager.
I started getting following error.
com.microsoft.sqlserver.jdbc.SQLServerException: An existing connection was forcibly closed by the remote host ClientConnectionId:xxxx
FYI: I have already tried adding below parameters in connection string.
EDIT 1
- Another important point - It's happening only for windows authentication (enabled via IntegratedSecurity=true; in connection string). So this case is happening only when Force encryption is set to true and we try to connect in windows authentication mode.
Open SQL Server Management Studio. In Connect to Server, select Database Engine, enter your SQL Server name, and enter administrator credentials to connect to the server. Select Connect. In Object Explorer, expand the SQL Server, expand Security, right-click Logins, and then select New Login.
On the Security page, under Server authentication, select the new server authentication mode, and then click OK. In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server. In Object Explorer, right-click your server, and then click Restart.
Using SQL Server Configuration Manager, right-click SQL Server Native Client Configuration, and then select Properties. On the Flags page, in the Force protocol encryption box, select Yes.
There are two possible modes: Windows Authentication mode and mixed mode. Windows Authentication mode enables Windows Authentication and disables SQL Server Authentication. Mixed mode enables both Windows Authentication and SQL Server Authentication. Windows Authentication is always available and cannot be disabled.
@Vivien @MarkRotteveel Thanks for your answers which gave me directions.
It turned out that sql server with version less then 11.0 were having troubles and various improvements were done as part of 11.0 version of sql server which rectified errors of windows authentication + encrypted connections connectivity.
So Sql server 2012 and above will support windows authentication with TLSv1.2, windows authentication along with encrypted connections seamlessly. Now I am using
Just for reference: Found on Microsoft website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With