title: SQL Server Pre-Login Handshake (error: 31 - Encryption(ssl/tls) handshake failed)
body: <p>I have a SQL server version <code>12.0.6205</code> and the following code in a .Net Core 3.1 (or 6) Web Api controller:</p>
  <pre><code> var builder = new SqlConnectionStringBuilder
  {
      DataSource = DataSource,
      UserID = UserID,
      Password = Password,
      InitialCatalog = InitialCatalog,
      ApplicationIntent = ApplicationIntent.ReadWrite,
      
      // Same result if true/true
      Encrypt = false,
      TrustServerCertificate = false
  };
  
  var connection = new SqlConnection(builder.ToString());
  using (var cmd = new SqlCommand() { Connection = connection, CommandText = &quot;SELECT TOP 1 * FROM [dbo].[Table]&quot; })
  {
      connection.Open(); // Breaks here
      var reader = cmd.ExecuteReader();
      Console.WriteLine(reader.HasRows);
  }
  </code></pre>
  <p>Locally this code works without issues but when executing in Azure's App service it breaks when opening the connection with:</p>
  <pre><code>System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)
  </code></pre>
  <p>I also have been able to reproduce the error, locally, if creating
  a docker imaged based on <code>appsvc/dotnetcore</code> (any tag)</p>
  <pre><code>FROM mcr.microsoft.com/appsvc/dotnetcore:3.1-latest_20220105.1
  
  ENV ASPNETCORE_URLS=http://+:80  
  
  EXPOSE 8080
  WORKDIR /home/site/wwwroot/
  COPY . .
  
  ENTRYPOINT [&quot;dotnet&quot;, &quot;Test.dll&quot;]
  </code></pre>