swagger-api / swagger-api/swagger-codegen
[csharp] How can I tell generated code to ignore certificates
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I used swagger-codegen to generate C# classes that, among other things, log into an application. However, I the login to work because the site I'm connecting to uses a self-signed certificate. I've hunted around the Web and found the most common answer is to add this to my code:
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
But this doesn't work, or at least it doesn't work for me. Should this work with the code generated from swagger-codegen or is there another way to tell the underlying web framework to ignore certificate errors?
I'm using swagger-codegen version 2.4.18-SNAPSHOT with .NET Core V5.0.
Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the generated C# client and how it performs requests under .NET Core 5.0, then compare that behavior with the certificate-validation callback described in the issue. Done means identifying whether the generated client supports configuring certificate validation and documenting the applicable configuration or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100