Core: dotnet restore fails

Created on 7 Jun 2018  ·  18Comments  ·  Source: dotnet/core

These are the errors I received after running dotnet-sdk.dotnet restore:

/snap/dotnet-sdk/18/sdk/2.1.300/NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/home/tristan957/Projects/full-stack-forum/full-stack-forum.csproj]
/snap/dotnet-sdk/18/sdk/2.1.300/NuGet.targets(114,5): error :   The SSL connection could not be established, see inner exception. [/home/tristan957/Projects/full-stack-forum/full-stack-forum.csproj]
/snap/dotnet-sdk/18/sdk/2.1.300/NuGet.targets(114,5): error :   The remote certificate is invalid according to the validation procedure. [/home/tristan957/Projects/full-stack-forum/full-stack-forum.csproj]

This was after I ran dotnet-sdk.dotnet new reactredux

Most helpful comment

Chasing another issue has lead me to a possible solution for this one ;-) Looks like this is related to the switch to SocketsHttpHandler (see the 2.1 Preview 2 blog post).

@tristan957 - I was able to get restore working on my Solus box by first running export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0. Once I did that, dotnet restore worked.

All 18 comments

Hi @tristan957 - This is an issue on a few distros that I haven't gotten to the bottom of yet. Let me shake some bushes around here and figure out what conditions can lead to the errors.

Sorry if this is a duplicate. Thanks for the response. Let me know if I can provide you with any information

Don't know yet if it's related but found this - https://github.com/dotnet/corefx/issues/29942

@leecow should we move this to the nuget repo to track it to start?

Chasing another issue has lead me to a possible solution for this one ;-) Looks like this is related to the switch to SocketsHttpHandler (see the 2.1 Preview 2 blog post).

@tristan957 - I was able to get restore working on my Solus box by first running export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0. Once I did that, dotnet restore worked.

Interesting. Is there something special about Solus that I should bring up to my distro maintainers, or is this solely a .NET Core issue? Would I experience this issue on other distros?

I think it may have more to do with Ubuntu Core which is the root of the Snap environment where snaps really run. Still need to poke around a bit more.

No rush. If you need me to test things on my end, let me know

Issue moved to dotnet/core-setup #4295 via ZenHub

I'm getting this with the Win 10 distro.

Hi.
I have the same problem on windows 7

C:\1\ConsoleApp1
λ dotnet restore
  Идет восстановление пакетов для C:\1\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj...
  Идет восстановление пакетов для C:\1\ConsoleApp1\UnitTestProject1\UnitTestProject1.csproj...
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/system.xml.xpath.xmldocument/index.json".
  The SSL connection could not be established, see inner exception.
    Authentication failed because the remote party has closed the transport stream.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/system.xml.xpath.xmldocument/index.json".
  The SSL connection could not be established, see inner exception.
    Authentication failed because the remote party has closed the transport stream.
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error : Не удалось извлечь данные о "System.Xml.XPath.XmlDocument" из удаленного источника "https://api.nuget.org/v3-flatcontainer/system.xml.xpath.xmldocument/index.json". [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   The SSL connection could not be established, see inner exception. [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   Authentication failed because the remote party has closed the transport stream. [C:\1\ConsoleApp1\ConsoleApp1.sln]
λ dotnet --info
Пакет SDK для .NET Core (отражающий любой global.json):
 Version:   2.2.101
 Commit:    236713b0b7

Среда выполнения:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.101\

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.301 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.401 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Disable SocketsHttpHandler

C:\1\ConsoleApp1
λ SET DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0

C:\1\ConsoleApp1
λ dotnet restore
  Идет восстановление пакетов для C:\1\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj...
  Идет восстановление пакетов для C:\1\ConsoleApp1\UnitTestProject1\UnitTestProject1.csproj...
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/mstest.testframework/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/mstest.testadapter/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/microsoft.testplatform.testhost/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Не удалось скачать пакет "Dapper.1.50.5" из "https://api.nuget.org/v3-flatcontainer/dapper/1.50.5/dapper.1.50.5.nupkg".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/microsoft.codecoverage/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/mstest.testadapter/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/microsoft.codecoverage/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/mstest.testframework/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Повторяется попытка выполнить операцию "FindPackagesByIdAsync" для источника "https://api.nuget.org/v3-flatcontainer/microsoft.testplatform.testhost/index.json".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
  Не удалось скачать пакет "Dapper.1.50.5" из "https://api.nuget.org/v3-flatcontainer/dapper/1.50.5/dapper.1.50.5.nupkg".
  An error occurred while sending the request.
    Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'.
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error : Не удалось скачать пакет "Dapper.1.50.5" из "https://api.nuget.org/v3-flatcontainer/dapper/1.50.5/dapper.1.50.5.nupkg". [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error : An error occurred while sending the request. [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'. [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error : Не удалось извлечь данные о "Microsoft.CodeCoverage" из удаленного источника "https://api.nuget.org/v3-flatcontainer/microsoft.codecoverage/index.json". [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   An error occurred while sending the request. [C:\1\ConsoleApp1\ConsoleApp1.sln]
C:\Program Files\dotnet\sdk\2.2.101\NuGet.targets(114,5): error :   Error 12030 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Соединение с сервером было неожиданно прервано'. [C:\1\ConsoleApp1\ConsoleApp1.sln]

@dmitriy-shleht the fact you're seeing the problem with and without SocketsHttpHandler hints it is likely some problem in your environment. Maybe misconfigured network, proxy, or something?
Try to isolate a repro (start with HelloWorld). Check accessibility of the endpoints, etc. Look at network capture traces (e.g. Wireshark/Fiddler) to see what's going on.
You can also try another VM with the same or newer OS to confirm it is not one machine problem.

Thank. The problem was in the internet provider. Began to use a proxy and everything is ok.
It is not clear why in the browser api.nuget.org worked, and through dotnet.exe there was an exception.

Thank. The problem was in the internet provider. Began to use a proxy and everything is ok.
It is not clear why in the browser api.nuget.org worked, and through dotnet.exe there was an exception.

Thanks for the tipp! Switching carriers did the trick for me, too!

Hi everyone,
I am struggling with this issue since Monday while running dotnet restore. Locally everything is fine - I can restore and build projects. Could anyone help?

/usr/share/dotnet/sdk/2.1.801/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/app/sqlModule.csproj] /usr/share/dotnet/sdk/2.1.801/NuGet.targets(123,5): error : The SSL connection could not be established, see inner exception. [/app/sqlModule.csproj] /usr/share/dotnet/sdk/2.1.801/NuGet.targets(123,5): error : The remote certificate is invalid according to the validation procedure. [/app/sqlModule.csproj]

I have reinstalled Docker (latest - 2.1.0.1, 2.0.0.3), updated VS 2019.
I've been trying docker images with SDK 2.1, 2.2, same issue.

I have found on other topics (probably on stackoverflow) that installing libcurl3 would help - nope.

I have added proxy in devenv.exe.config:

<defaultProxy 
  enabled="false"  
  useDefaultCredentials="true">
</defaultProxy>  

I have been trying set the following env variable:
RUN export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0

Some information about dotnet version:

Step 10/17 : RUN dotnet --info
 ---> Running in bbf256d6dc4e
.NET Core SDK (reflecting any global.json):
 Version:   2.1.801
 Commit:    c404ee777a

Runtime Environment:
 OS Name:     debian
 OS Version:  9
 OS Platform: Linux
 RID:         debian.9-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.801/

Host (useful for support):
  Version: 2.1.12
  Commit:  ccea2e606d

.NET Core SDKs installed:
  2.1.801 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Honestly I have no idea what do next, any hints?

Refer to the other solutions in this thread https://github.com/dotnet/core-setup/issues/4295. Perhaps those will help.

I'm trying to do a restore from a Dockerfile such as this:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 as builder

COPY ./ts.sln NuGet.config ./
COPY .//.csproj ./

RUN dotnet restore

And I'm getting these errors:

Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/nuget.common/index.json'.
The SSL connection could not be established, see inner exception.
Received an unexpected EOF or 0 bytes from the transport stream.

I would like to mention that certificate related issues are common in enterprise environments. Usually when connecting to external networks (api.nuget.org), for security reasons, network traffic will go via proxy. This proxy may be configured to sign all https traffic with own certificate. If this certificate is not added to trust stores of a particular system or software package and the system is not configured to accept all certificates, then the connection will fail.

The question which should be asked here is: for dotnet restore command, does there exist a switch to accept all certificates by default and what is the location where a certificate public key can be placed so that a particular certificate is trusted? On linux, this is usually done with .crt files being saved in a particular folder, and certificate is retrieved by a command such as:

https://unix.stackexchange.com/questions/552778/how-to-export-all-certificates-in-a-certificate-chain-to-separate-crt-files-wit/552818#552818

(openssl s_client -showcerts -connect <host>:<port> & sleep 4) | awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/{if(/-----BEGIN CERTIFICATE-----/){a++}; out="/tmp/<host>"a".crt"; print > out}'

Was this page helpful?
0 / 5 - 0 ratings