使用Couchbase dotnet sdk时,MacOS上的DotNet Core 2.0会收到httpclient触发的libcurl和ssl错误 [英] DotNet core 2.0 on MacOS gets libcurl and ssl error triggered by httpclient when using couchbase dotnet sdk

查看:108
本文介绍了使用Couchbase dotnet sdk时,MacOS上的DotNet Core 2.0会收到httpclient触发的libcurl和ssl错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Dotnet core 2.x(实际上是在编写此文件时使用的是最新版本2.1.4)Web api项目,为了将Couchbase用作数据库服务器,我需要使用Couchbase SDK。 sdk声明它支持DotNet core 2.x。

I am developing an Dotnet core 2.x(actually using 2.1.4, latest release when I'm writing this) web api project, in order to use couchbase as my database server, I need to use the couchbase SDK. The sdk states that it supports DotNet core 2.x.

在进行了非常基本的设置之后,我只想测试连接性,所以我一直收到此错误。

After a very basic setup and I just want to test the connectivity, I keep getting this error.


HttpRequestException:该处理程序不支持使用libcurl(7.54.0)及其SSL后端( LibreSSL / 2.0。 20)。

HttpRequestException: The handler does not support custom handling of certificates with this combination of libcurl (7.54.0) and its SSL backend ("LibreSSL/2.0.20").

我以为这是沙发床SDK的问题,但经过一番研究,我发现这与macOS有关内置的openssl和curl不支持某些行为。以下是一些参考:

I thought this is a issue with the couchbase SDK, but after some research, I found it is about the macOS built-in openssl and curl does not support certain behavior. Here are some reference:

。NET Core,OSX,libcurl和OpenSSL

Couchbase dotnet SDK OSX libcurl错误

经过更多研究后,结果发现dotnet core 2.0不再受MacOS相关问题的困扰...但是为什么我仍然得到这个?

after some more research, it turns out that dotnet core 2.0 should no longer suffer from the MacOS related issue...But why am I still getting this?

是否有任何变通办法,比如告诉HttpClient使用curl的brew版本?

Is there any workaround like telling HttpClient to use brew version of curl?

推荐答案

使用套接字HTTP处理程序的步骤



这是我需要执行的操作:

Steps to Use Socket HTTP Handler

Here's what I needed to do to get this to work:


  • 安装.NET Core SDK 2.1.xxx预览

  • 更新项目 AspNetCore.All 参考
  • 将软件包源添加到 NuGet.Config

  • 设置环境变量

  • Install .NET Core SDK 2.1.xxx-preview
  • Update Project AspNetCore.All Reference
  • Add Package Source to NuGet.Config
  • Set Environment Variable

下载并安装 macOS安装程序

更新软件包参考:

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-preview1-final" />



将软件包源添加到 NuGet.Config



更新〜/ .nuget / NuGet / NuGet.Config 并添加另一个包源:

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" />

我需要这样做,因为我遇到了NuGet错误:
错误NU1102:无法找到版本(> = 2.1.0)的软件包Microsoft.AspNetCore.All。

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).

在我的 Startup.cs 中,我设置了一个环境变量:

In my Startup.cs I set an environment variable:

Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER", "true");



我们在做什么



2.1 dotnet将合并其自己的套接字处理程序,从而绕过特定于OS的套接字处理程序,因此我们可以避免macOS问题。在Preview-1中,我们仍然必须手动选择加入:
https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs

但是很快在Preview-2中它将默认打开:
https://github.com/dotnet/corefx/pull/27821

But soon in preview-2 it'll be on by default: https://github.com/dotnet/corefx/pull/27821

今天早上我一直在调查同一问题,目前我不认为有一个明确的解决方案。 Dotnet Core 2.x不能解决Couchbase SDK的问题,尽管我认为在Couchbase之外使用 HttpClient 很好(尚未对此进行测试)。

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).

自Couchbase SDK 2.5.8版(2018年3月17日)起,这仍然是一个已知问题:
https://developer.couchbase.com/server/other-products/release-notes-archives/dotnet -sdk

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

实际问题链接:
https://issues.couchbase.com/browse/NCBC-1296

在论坛中,请参阅:

  • 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.

这篇关于使用Couchbase dotnet sdk时,MacOS上的DotNet Core 2.0会收到httpclient触发的libcurl和ssl错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆