Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlClient CryptographicException is back on High Sierra 10.13.4 #25690

Closed
winzig opened this issue Mar 30, 2018 · 25 comments
Closed

SqlClient CryptographicException is back on High Sierra 10.13.4 #25690

winzig opened this issue Mar 30, 2018 · 25 comments
Milestone

Comments

@winzig
Copy link

winzig commented Mar 30, 2018

My issue today seems the same as this: https://github.com/dotnet/corefx/issues/22453

Yesterday (on High Sierra 10.13.3) my .net core 2.0 web project ran fine, connecting to SQL Server.

Last night my machine was updated to 10.13.4, and now this morning when I run the project I get this error:

An unhandled exception was thrown by the application.
System.TypeInitializationException: The type initializer for 'XXX' 
threw an exception. ---> System.Data.SqlClient.SqlException: 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) ---> 
System.Security.Cryptography.CryptographicException: 
Error occurred during a cryptographic operation.

Anyone else on 10.13.4 able to successfully connect to SQL Server this morning?

@danmoseley
Copy link
Member

@bartonjs

@bartonjs
Copy link
Member

Confirmed. Sigh. Looking into why.

@bartonjs bartonjs self-assigned this Mar 30, 2018
@bartonjs
Copy link
Member

It looks like they've made some fundamental changes to X509Chain processing in 10.13.4.

@bartonjs
Copy link
Member

Okay, maybe less fundamental than I thought. Apparently my test rig was in a corrupted state.

@danmoseley
Copy link
Member

@MattGal how do we get or test boxes updated to 10.13.4? In general if they updated automatically that would be a good thing.

@winzig
Copy link
Author

winzig commented Mar 31, 2018

@bartonjs Thanks for fixing this so rapidly. What would be the best way for me to go about getting this on my system until the next release of core? Can I just clone and build this repo and drop it somewhere into my system?

Update: Just found this page which describes how to dog food the latest corefx, so I’ll try that.

@bartonjs
Copy link
Member

@winzig If you want to peel back the tamper-evident seal and void the warranty you could do something like

  • Pull down the repository
  • ./build-native.sh -release
  • locate System.Security.Cryptography.Native.Apple.dylib
  • For each of those in a 2.x release, cp bin/OSX.x64.Release/native/System.Security.Cryptography.Native.Apple.dylib <dest>

Slightly safer would be to save the existing one before overwriting it, using my favorite bash syntax (or a less fun syntax, I guess...) cp <dest>{,.orig} (where <dest> is something you replace, and {,.orig} isn't 😄)

@winzig
Copy link
Author

winzig commented Apr 1, 2018

Crud, appreciate the help, but looks like I'm unable to build for some reason. I'll try to figure out what I'm doing wrong, but barring that, I'm assuming I'm waiting for an official release. Do you think it will make it in for 2.0.7? And is there an ETA on that release?

@MattGal
Copy link
Member

MattGal commented Apr 2, 2018

@danmosemsft I'm not sure about how to configured automated updates for OSX machines in a way that doesn't accidentally break things like OpenSSL building but I filed https://github.com/dotnet/core-eng/issues/3091 to track updating the 10.13 agents, please use this to track the update.

@bartonjs
Copy link
Member

bartonjs commented Apr 2, 2018

This was merged in for 2.0.7 with dotnet/corefx#28675. @leecow do we have a published target release date?

@leecow
Copy link
Member

leecow commented Apr 2, 2018

Targeting 4/17 pending validation.

@winzig
Copy link
Author

winzig commented Apr 3, 2018

Thanks @bartonjs, now that the build issue was resolved, I was able to implement your steps and get back up and running!

@bartonjs
Copy link
Member

bartonjs commented Apr 4, 2018

(From a comment on the rel/2.0 PR)

With last version 2.1.300-preview3-008437 on Mac OSX High Sierra 10.13.4 (17E199) still happens.

$ tar -tzvf dotnet-sdk-latest-osx-x64.tar.gz  | grep "Apple.dylib\|csc.dll"
-rwxr-xr-x buildagent/staff    65724 2018-03-14 09:06 ./shared/Microsoft.NETCore.App/2.1.0-preview2-26314-02/System.Security.Cryptography.Native.Apple.dylib
-rw-r--r-- buildagent/staff   101376 2018-04-03 11:38 ./sdk/2.1.300-preview3-008437/Roslyn/bincore/csc.dll

So SDK 2.1.300-preview3-008437 contains runtime 2.1.0-preview2-26314-02.

The latest runtime from https://github.com/dotnet/core-setup#daily-builds, on the other hand:

$ tar -tzvf dotnet-runtime-latest-osx-x64.tar.gz | grep Apple.dylib
-rwxr-xr-x buildagent/staff    65724 2018-04-03 21:06 ./shared/Microsoft.NETCore.App/2.1.0-preview3-26404-01/System.Security.Cryptography.Native.Apple.dylib

Is version 2.1.0-preview3-26404-01. The fix went into master on 31 March, so any 2.1.0-preview2-2640* build should have it.

So the SDK is currently lagging by a couple of weeks, it seems. But you can grab the runtime package and use it with an existing SDK.

@bartonjs
Copy link
Member

bartonjs commented Apr 6, 2018

Since the fixes for 2.0 and 2.1 are both already in, and things are just waiting on releases to happen, I'm going to close this issue. Closed != locked, so feel free to add information if things like grabbing a latest daily 2.1 (or manually patching 2.0) don't fix the issue for you.

@bartonjs bartonjs closed this as completed Apr 6, 2018
@derekclevenger
Copy link

derekclevenger commented Apr 17, 2018

Was this fix implemented with 2.0.7?

@reintjanhoiting-zz
Copy link

reintjanhoiting-zz commented Apr 17, 2018

@derk2689 yes, it will. but I don't believe the 2.0.7 is not officially released yet. It was scheduled to be released tomorrow.

in the meantime, you can consume a daily runtime: https://github.com/dotnet/core-setup#daily-builds
if its released it will popup on this page: https://github.com/dotnet/core/releases

@derekclevenger
Copy link

Thanks for the quick response. I updated and it said my current version was 2.0.7 but I will wait and see tomorrow if something changes on it. Thanks again for the help.

@bartonjs
Copy link
Member

dotnet/core#1456 says that 2.0.7 is out now. The build labels say that the 10.13.4 changes were included, so upgrading to the 2.0.7 runtime should resolve the problems.

@derekclevenger
Copy link

Just got this running from cli. Thanks for all the work and help to all involved.

@lannsjo
Copy link

lannsjo commented Apr 18, 2018

Thank you! I have updated to 2.0.7 and everything works fine in Sierra 10.13.4 now!

@eddiedozier
Copy link

Thanks for the fix guys!

@nn-afly
Copy link

nn-afly commented May 3, 2018

👍

@jdk339
Copy link

jdk339 commented May 11, 2018

I still seem be getting the same error

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLDNAJG8PIG7", Request id "0HLDNAJG8PIG7:00000001": An unhandled exception was thrown by the application.
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) ---> System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation

Here is my .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
  </ItemGroup>
</Project>

This error only appeared after updating to macOS High Sierra 10.13.4.

I knew I shouldn't have updated!

@ghost
Copy link

ghost commented May 11, 2018

@jdk339, you would need to update dotnet installation: https://www.microsoft.com/net/learn/get-started/macos

@jdk339
Copy link

jdk339 commented May 11, 2018

@kasper3 Awesome, that worked. Thanks a lot!

@bartonjs bartonjs removed their assignment Nov 23, 2018
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests