DotNet core 2.0 on MacOS gets libcurl and ssl error triggered by httpclient when using couchbase dotnet sdk
Steps to Use Socket HTTP Handler
Here's what I needed to do to get this to work:
- Install .NET Core SDK 2.1.xxx-preview
- Update Project
AspNetCore.All
Reference - Add Package Source to
NuGet.Config
- Set Environment Variable
Install .NET Core SDK [2.1.xxx-preview]
Download and install macOs installer
Update Project AspNetCore.All
Reference
Update package reference to:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-preview1-final" />
Add Package Source to NuGet.Config
Update ~/.nuget/NuGet/NuGet.Config
and add another package source:
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
I needed to do this because I was getting a NuGet error:error NU1102: Unable to find package Microsoft.AspNetCore.All with version (>= 2.1.0)
.
Set Environment Variable
In my Startup.cs
I set an environment variable:
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER", "true");
What We're Doing
With 2.1 dotnet will incorporate its own Socket Handler which bypasses OS specific ones and so we can avoid the macOS issues. In preview-1 we still have to manually opt-in:https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
But soon in preview-2 it'll be on by default:https://github.com/dotnet/corefx/pull/27821
Previous post
I've been investigating the same issue this morning and I currently don't think there's a clear solution. Dotnet Core 2.x does not resolve the issue for the Couchbase SDK, though I think using HttpClient
outside of Couchbase is fine (haven't tested this).
As of Couchbase SDK Version 2.5.8 (17 March 2018) this is still a known issue:https://developer.couchbase.com/server/other-products/release-notes-archives/dotnet-sdk
Actual issue link:https://issues.couchbase.com/browse/NCBC-1296
In the forums, see:
- https://forums.couchbase.com/t/couchbase-dotnet-sdk-osx-libcurl-error/12238
- https://forums.couchbase.com/t/platformnotsupportedexception-when-querying-from-net-core-2-0-on-macos/15490/6
I'll post back if I find a working solution.