Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Support self signed certificates #345

Open
daniellwdb opened this issue Apr 11, 2021 · 2 comments
Open

Support self signed certificates #345

daniellwdb opened this issue Apr 11, 2021 · 2 comments

Comments

@daniellwdb
Copy link

daniellwdb commented Apr 11, 2021

Is your feature request related to a problem? Please describe.
I finally set up a dotnet core API with swagger and local https using a self signed certificate. Now I tried to consume the generated swagger.json so I created a command:

{
  "generate-fetcher": "restful-react import --url https://localhost:5001/swagger/v1/swagger.json --output src/generated/fetchers.tsx"
}

Unfortunately this results in a clear error

❯ npm run generate-fetcher                    

> todo-app@0.1.0 generate-fetcher
> restful-react import --url https://localhost:5001/swagger/v1/swagger.json --output src/generated/fetchers.tsx

Error: self signed certificate

Describe the solution you'd like
It would be nice if we can somehow trust this certificate, however I lack knowledge to get a clear idea of what this would look like.

Describe alternatives you've considered
The current workaround is to set the NODE_TLS_REJECT_UNAUTHORIZED environment variable

{
  "generate-fetcher": "NODE_TLS_REJECT_UNAUTHORIZED='0' restful-react import --url https://localhost:5001/swagger/v1/swagger.json --output src/generated/fetchers.tsx"
}
@fabien0102
Copy link
Contributor

Good to know, I think we should just add your workaround in the README.md I don't really better idea for this edge case 😅

@daniellwdb
Copy link
Author

daniellwdb commented Apr 11, 2021

It seems like another solution could be to add strictSSL: false to the urlSpecReq options, maybe this property could be added dynamically with a flag so that people don't have to depend on cross-env or set the environment variable globally, I did some reading and it's also possible to pass certificate options to the request options but I don't think it's easy to implement this because there are different kinds of certificates, .pfx must be parsed before used but even after I did that I couldn't get it to work, maybe somebody wants to look into that in the future

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants