Add custom ssl_context to aiohttp helper#84573
Conversation
|
Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
Hey there @bdraco, @shbatm, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
| def async_create_clientsession( | ||
| hass: HomeAssistant, | ||
| verify_ssl: bool = True, | ||
| ssl_context: bool | SSLContext = True |
There was a problem hiding this comment.
This is a breaking change. Maybe keep the old parameter while adding the new parameter next to the old?
There was a problem hiding this comment.
That is a good idea, schould I log a warning when the old parameter is used that it will be deprecated?
There was a problem hiding this comment.
If we want to deprecate the old parameter, yes. I'm not sure if we want that. Let's hear what others think first.
There was a problem hiding this comment.
I agree with Martin. We should keep both parameters here. See my comment above as well.
|
A alternative to this PR would be to replace the But I do not know enough about aiohttp and ssl, to comfortably make that change. |
| port = host.port or 80 | ||
| session = aiohttp_client.async_create_clientsession( | ||
| hass, verify_ssl=False, cookie_jar=CookieJar(unsafe=True) | ||
| hass, ssl_context=False, cookie_jar=CookieJar(unsafe=True) |
There was a problem hiding this comment.
The behavior here is a bit unexpected. If ssl_context is false it seems to imply a non secure connection
balloob
left a comment
There was a problem hiding this comment.
We shouldn't merge this. The one custom component that needs this should just create their own ClientSession instead of trying to adjust a generic helper.
We haven't needed it until now, and a single instance is not good enough to drive this change.
|
Alright, I will just use a separate clientsession for the new reolink integration. |
Breaking change
For custom components only:
The verify_ssl optional argument of the
async_create_clientsessionhas been renamed tossl_contextand now allows to pass in a ssl_context besides a boolean value.Proposed change
Allow to specify custom ssl_context in the
async_create_clientsessionfunction of the aiohttp_client helper.This can be needed to prevent the
[[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:992)]error.This error can be solved by passing in a custom ssl_context:
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.To help with the load of incoming pull requests: