Reputation: 45
I recently wiped my laptop and reinstalled everything, including Visual Studio. Since doing so, my connection string for an intranet web app (connecting to a local SQL Server DB) no longer works in debug...
<add name="Company Database" connectionString="Data Source=Server\Instance;Initial Catalog="DBName";Persist Security Info=True;User ID=User;Password=Pass" providerName="System.Data.SqlClient" />
It works fine when deployed to a server, but when I try to run the app in debug I get the error "SSL Provider, error 0 - The certificate chain was issued by an authority that is not trusted". The posts I've found matching this error typically suggest to use (with caution for an external facing app) encrypt=false or TrustServerCertificate=true. When I try these, the text is underlined in green and tooltip displays "the encrypt attribute is not allowed". Have tried updating "System.Data.SQLClient" to "Microsoft.Data.SQLClient" but this doesn't appear to make any difference. Can anyone assist please? Thanks
Upvotes: 0
Views: 2377
Reputation: 11
Check the "Trust server certificate" and press the Connect button.
Upvotes: 1
Reputation: 1
I got resolved the issue using Self-Signed Certificate Using IIS Manager
Steps to Resolve the Error
Step 1. Generate a Self-Signed Certificate Using IIS Manager
Step 2. Bind the Certificate to SQL Server
Open SQL Server Configuration Manager:
Expand SQL Server Network Configuration.
Select Protocols for [Your SQL Instance Name].
Right-click Properties for the protocol named TCP/IP and confirm it's Enabled.
Go back to SQL Server Configuration Manager and select the SQL Server [Your SQL Instance Name] node in SQL Server services.
Open the Certificate tab:
Apply and restart the SQL Server service for the changes to take effect.
Upvotes: 0
Reputation: 1
add these two properties to your connection string: TrustServerCertificate=True;Encrypt=False
Upvotes: -1