pdevito3 / craftsman

A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
https://wrapt.dev
MIT License
1.12k stars 65 forks source link

SSL error on sql client for integration tests #80

Closed pdevito3 closed 2 years ago

pdevito3 commented 2 years ago

Steps to reproduce

Running integration tests for sql server cause this:

OneTimeSetUp: Microsoft.Data.SqlClient.SqlException : A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
Data:
  HelpLink.ProdName: Microsoft SQL Server
  HelpLink.EvtSrc: MSSQLServer
  HelpLink.EvtID: -2146893019
  HelpLink.BaseHelpUrl: https://go.microsoft.com/fwlink
  HelpLink.LinkId: 20476
  ----> System.ComponentModel.Win32Exception : The certificate chain was issued by an authority that is not trusted.
  Exception doesn't have a stacktrace

Further technical details

Craftsman version (dotnet tool list -g): 14.x

pdevito3 commented 2 years ago

This is because sql client v4 had a breaking change to have encrypt set to true by default

https://docs.microsoft.com/en-us/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace?view=sql-server-ver15#breaking-changes-in-40

Need to set it to false in the connection string:

dockerConnectionString += ";TrustServerCertificate=True;"; Environment.SetEnvironmentVariable("DB_CONNECTION_STRING", dockerConnectionString);