visual-studio-2015nugetnuget-packagenuget-server

Visual studio nuget is not using the HTTPS configured feed and use HTTP instead


I have created a nuget teamcity feed on a https url :

https://teamcity:xyz/httpAuth/app/nuget/v1/FeedService.svc/

When I push to this url or list package in visual studio it works but when I install the package from the package management console or the visual nuget package management tool in visual studio I see that it try to download from http feed but this does not work and give a timeout because the teamcity is only open and allow on https port.

Retrieving package 'Test 1.0.0' from 'SAI'.
  GET     http://teamcity:xyz/httpAuth/app/nuget/v1/FeedService.svc/download/Package/4646:i    d/Test.1.0.0.0.nupkg

I receive a timeout :
Retrieving package 'Test 1.0.0' from 'TEST'.
 GET       http://teamcity:xyz/httpAuth/app/nuget/v1/FeedService.svc/download/Test/4646:id/T    est.1.0.0.0.nupkg
.... 
...
has timed out after 100000ms.

So, why Visual studio is using http? When i look in the nuget config file I can see that the feed url is configured with HTTPS?

<packageSources>
 <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
 <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
 <add key="TEST" value="https://teamcity:xyz/httpAuth/app/nuget/v1/FeedService.svc/" />
</packageSources>

Solution

  • why Visual studio is using http? When i look in the nuget config file I can see that the feed url is configured with HTTPS?

    That is because the TeamCity server return an http url for download, and nuget.exe/Visual Studio extension just follows the link. In this case, Visual Studio/NuGet is not using the HTTPS configured feed and uses HTTP instead.

    Besides, NuGet server (nuget.org) and TeamCity are only allow on https port, so all the feed links and auth would be messed up since http:// is incorrect and will get redirected to https://. This also means the auth header isn't re-sent, so it results in a redirected loop. Then we will get the time out issue.

    To resolve this issue, you can try to modify the /<TeamCityDir>/conf/server.xml section to include the last 3 attributes to make it behave properly behind an SSL-terminating proxy:

    <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
           connectionTimeout="60000"
           redirectPort="8543"
           useBodyEncodingForURI="true"
           socket.txBufSize="64000"
           socket.rxBufSize="64000"
           tcpNoDelay="1"
           secure="true"
           scheme="https"
           proxyPort="443"
    />
    

    For more detail information, you can refer to the issue on GitHub: VS Extension attempts to download package via HTTP when source is HTTPS