gql icon indicating copy to clipboard operation
gql copied to clipboard

AIOHTTPTransport ssl=False by default

Open mariuskava opened this issue 1 year ago • 5 comments

Common problems

  • TLS should be enabled by default. AIOHTTPTransport uses ssl=False by default
  • I was expecting library to fail when using self signed certificate on the server.

To Reproduce

  • start a server with a self signed certificate
  • try connect
  • it will succeed instead of failing

Expected behavior Expect connection to fail when using not trusted certificates

System info (please complete the following information):

  • Any

mariuskava avatar Feb 17 '25 18:02 mariuskava

That's pretty bad... Thanks for your report.

The annoying thing is that there are probably some people which are depending on this and changing the default will be a breaking change for them.

A major version bump will be needed to fix this.

leszekhanusz avatar Feb 17 '25 23:02 leszekhanusz

yes, there must be a breaking change.. but a patch release could contain a warning:

  • default should be changed to ssl=None
  • if ssl==None: log warning and set ssl=False

mariuskava avatar Feb 17 '25 23:02 mariuskava

yes, there must be a breaking change.. but a patch release could contain a warning:

Good idea!

leszekhanusz avatar Feb 17 '25 23:02 leszekhanusz

Note that for the warning, the default value cannot be None.

That's because there was a change in aiohttp from version 3.10

Before aiohttp 3.10, aiohttp was using None as the default value, and would verify the certification in that case. From aiohttp 3.10, it switched to use True as the default value.

So, someone could have used ssl=None previously with AIOHTTPTransport. He would have a typing error with mypy but it would work and gql would verify the certificate. If we set ssl to False if we receive None, then gql will not verify the cert for him in that case.

We could use another default value, like the "warning" string?

leszekhanusz avatar Feb 18 '25 00:02 leszekhanusz

good point. Default string value sounds good enough or it could be a predefined sentinel = object() https://python-patterns.guide/python/sentinel-object/#sentinel-objects

mariuskava avatar Feb 18 '25 00:02 mariuskava

Fixed in version 4.0.0

leszekhanusz avatar Aug 17 '25 14:08 leszekhanusz