swagger-api / swagger-api/swagger-codegen

[CSHARP] Bug - Nuget TLS1.2 Client Build fails

Open
#10,341 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Code generation of CSharp Client does not work anymore. Nuget Download requests tls1.2 protocol.
See:
https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org/

Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure 

channel."

At line:1 char:1

+ (new-object System.Net.WebClient).DownloadFile('https://dist.nuget.or ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : WebException

'.\nuget.exe' is not recognized as an internal or external command,
operable program or batch file.
Swagger declaration file content or url

modules/swagger-codegen/src/main/resources/csharp/compile.mustache

Line 13:
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
.\nuget.exe install src\{{packageName}}\packages.config -o packages

Suggest a fix/enhancement

Line 13: Replace with protocol settings.

if not exist ".\nuget.exe" powershell -Command "[System.Net.ServicePointManager]::SecurityProtocol+=[System.Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
.\nuget.exe install src\{{packageName}}\packages.config -o packages

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect modules/swagger-codegen/src/main/resources/csharp/compile.mustache, especially line 13 and the surrounding NuGet download commands. Verify the generated C# client build path and confirm that the NuGet download and package installation complete successfully when TLS 1.2 is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
build-system, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.