optimade-python-tools icon indicating copy to clipboard operation
optimade-python-tools copied to clipboard

SSL verification is not turned off despite setting skip_ssl = True

Open mehmetgiritli opened this issue 1 year ago • 4 comments

Instantiating OptimadeClient with the skip_ssl flag like so:

from optimade.client import OptimadeClient

client = OptimadeClient(skip_ssl= True, ...)

Does not really have any effect on disabling SSL verification. I was able to sort myself out for the time being by hacking away here:

https://github.com/Materials-Consortia/optimade-python-tools/blob/86f7fa8bc31af30c6f4ed1fdcce271a24e245719/optimade/client/client.py#L950

into this:

async with self._http_client(headers=self.headers, verify = not self.skip_ssl) as client:  # type: ignore[union-attr,call-arg,misc]

Not sure of the ramifications tough.

mehmetgiritli avatar Aug 12 '24 15:08 mehmetgiritli

Thanks @mehmetgiritli, this is probably just a poorly named option, the SSL skip is only meant to apply to downloading of the providers list (which had an expired cert at some point). I don't think I want to add SSL skipping generally. Do you have a use case for it?

ml-evs avatar Aug 12 '24 16:08 ml-evs

We are developing an Optimade APi with this library, but we also want to consume it using the client. Since the API is in various development environments and these tend to have self-signed certs, we need to have the client tolerate self-signed certs, while under development.

Hope that makes sense.

Thank you @ml-evs

mehmetgiritli avatar Aug 13 '24 08:08 mehmetgiritli

Ah I see, in that case I'd be happy to add a way to run the client with SSL turned off on a given URL, rather than allowing SSL-less requests to all of OPTIMADE. Would you be interested in preparing a PR containing the changes above? Otherwise I can take a look at this when I get a moment.

ml-evs avatar Aug 14 '24 11:08 ml-evs

OK, that makes sense. I'll do a PR when I get around to it. Thank you :-)

mehmetgiritli avatar Aug 15 '24 11:08 mehmetgiritli