Skip to content

Add --no-verify-ssl argument #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johnthagen opened this issue Oct 27, 2021 · 6 comments
Closed

Add --no-verify-ssl argument #531

johnthagen opened this issue Oct 27, 2021 · 6 comments
Labels
✨ enhancement New feature or improvement

Comments

@johnthagen
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Sometimes self-signed certificates are used during local development (for example when hosting over https://localhost). Currently openapi-python-client (rightly) fails to connect to self-signed HTTPS endpoints:

openapi-python-client generate --url https://localhost/openapi --fail-on-warning --meta setup
Error(s) encountered while generating, client was not created

Could not get OpenAPI document from provided URL

Describe the solution you'd like

Add a new --no-verify-ssl command line option that would allow developers to opt in to disabling SSL verification. This should of course not be the default.

Describe alternatives you've considered

openapi-generator supports this through the use of (hard to use/understand) Java environment variables:

export JAVA_TOOL_OPTIONS="-Dio.swagger.parser.util.RemoteUrl.trustAll=true -Dio.swagger.v3.parser.util.RemoteUrl.trustAll=true"

Ideally, a simple command line option would be much more discoverable and easy to use.

@johnthagen johnthagen added the ✨ enhancement New feature or improvement label Oct 27, 2021
@johnthagen
Copy link
Collaborator Author

I believe the no-verify bool would need to be passed to:

httpx docs: https://www.python-httpx.org/advanced/#changing-the-verification-defaults

import httpx

r = httpx.get("https://example.org", verify=False)

@mattmess1221
Copy link

mattmess1221 commented Feb 8, 2022

If you have the certificates installed on the system and you can connect with curl without the -k option, you can set the SSL_CERT_DIR or SSL_CERT_FILE environment variables. On ubuntu, it would be this.

export SSL_CERT_DIR=/etc/ssl/certs
openapi-python-client generate --url=https://yourhost/openapi.json

@rtaycher
Copy link
Contributor

rtaycher commented Feb 14, 2022

while it may not be quite what you want since its at
library use time instead of generation time
we do have a verify_ssl attr for Client
the user can set it to False or initialize it as False in the constructor
client.verify_ssl = False

If forcing the library user to do that is too much you could also set it to false
by default by modifying the client.py.jinja template in --custom-template-path folder

@dbanty
Copy link
Collaborator

dbanty commented Feb 17, 2022

You could also download the OpenAPI file locally first and then pass it as a --path to openapi-python-client instead of --url. I don't really want to get in the business of tweaking ways to fetch remote documents beyond the simple, no-config get request. I could maybe be convinced to add support for reading the spec from stdin so you could pipe from curl or something to be a bit more unixy then saving to a file.

@mattmess1221
Copy link

Bash will also let you pipe a command as a file.

openapi-python-client --path <(curl https://example.com/openapi.json)

@dbanty
Copy link
Collaborator

dbanty commented Jul 8, 2023

I think we're not going to add --no-verify-ssl, the workarounds provided by folks above seem good enough.

@dbanty dbanty closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

4 participants