-
Notifications
You must be signed in to change notification settings - Fork 24
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
Disable ssl VERIFY_X509_STRICT with self-signed certificate DNS #737
Conversation
The new flag enforced in Python 3.13 with python/cpython#107361 doesn't work with the semi broken Freebox self signed certificates. It should fix home-assistant/core#132333 Fixes hacf-fr#734
For me, this doesn't solve the problem described in home-assistant/core#132333. I had to disable certificate verification:
|
It's surprising. There is no reason for the SSL verification to work in python 3.12 and to start failing suddenly with 3.13. The main thing that changed with 3.13 is the 2 additional flags. Can you try disabling |
I tried to disable only VERIFY_X509_PARTIAL_CHAIN , but it didn't solve the problem. |
OK I'm not sure what's going on. I can confirm that this PR works for me with a Delta. |
Currently testing on Revolution |
@olivierh65 : what Freebox model, Freebox firmware version and Python version do you have ? |
From py3.11: OK ✅
To py3.13 after your PR: OK ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and working, thanks !
Co-authored-by: Quentame <polletquentin74@me.com>
I have the same issue on Freebox Delta. These are my configs: Python version = 3.13 and from : http://mafreebox.freebox.fr/api_version I get :
@Quentame How can I test your PR, pls? |
On my side :
{"box_model_name":"Freebox Server (r2)","api_base_url":"\/api\/","https_port":0000pp,"device_name":"Freebox Server","https_available":true,"box_model":"fbxgw-r2\/full","api_domain":"llllllllll.fbxos.fr","api_version":"12.2","device_type":"FreeboxServer1,2"}
If you create a new domain with a let's crypt certificat, and use this domain to connect the plug-in, it should work.
|
By running this file
What I wrote there home-assistant/core#132333 (comment) 😉 |
Yes, it was just a confirmation |
@@ -118,6 +118,10 @@ async def open(self, host: str, port: str) -> None: | |||
cert_path = os.path.join(os.path.dirname(__file__), "freebox_certificates.pem") | |||
ssl_ctx = ssl.create_default_context() | |||
ssl_ctx.load_verify_locations(cafile=cert_path) | |||
if ".fbxos.fr" in host or "mafreebox.freebox.fr" in host: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an host.endswith(".fboxos.fr")
and host = "mafreebox.freebox.fr"
would be safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, but I am finally not sure of keeping this check, as there is an issue with Italian Freeboxes : Illiadbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or using some kind of regex that should match both FR and ITA boxes.
As bo?x(os)?([\w\.]+)?\.[\w]{2,4}
, to match:
- invalid: .fbxos.fr
- invalid: mafreebox.freebox.fr
- valid: custom.freeboxos.fr
- invalid: .ibxos.it
- invalid: myiliadbox.iliad.it
- valid: custom.iliadboxos.it
But the issue is that this regex matches all DNS, including valid ones.
OK, found one that matches only invalid ones (bxos)|(box\.[\w]+)\.[\w]{2,4}
.
But not sure if this is even needed ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Free/the Iliad Group expend in an other country, we probably need to update that, and I don't really want to see an other issue for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Quentame If you want to do a regex, I think your last one is not strict enough (demo).
Iliad is not going to expand to other countries regularly so I don't know if it is worth opening the SSL exclusion that much. Also we can't know in advance what name they could take and even if we can guess a pattern (eg: myiliadbox.iliad.pt and .ibxos.pt if they expand to portugal), it would not be very secure to include all tlds.
I suggest instead to stay explicit and add exclusions on a case-by-case basis. It can be condensed into a regex but it must be strict enough (demo):
(mafreebox\.freebox\.fr$)|(\.fbxos\.fr$)|(myiliadbox\.iliad\.it$)|(\.ibxos\.it$)
And if they continue along the lines of iliad.tld/.ibxos.tld then it will be enough to add these tlds in the regex (demo):
(mafreebox\.freebox\.fr$)|(\.fbxos\.fr$)|(myiliadbox\.iliad\.(it|pt|co\.uk)$)|(\.ibxos\.(it|pt|co\.uk)$)
If you really want to be more permissive to avoid future code edit, you could allow all country tlds like this (demo) :
(mafreebox\.freebox\.fr$)|(\.fbxos\.fr$)|(myiliadbox\.iliad\.([a-z]{2,4}|co\.uk)$)|(\.ibxos\.([a-z]{2,4}|co\.uk)$)
The new flag enforced in Python 3.13 with
python/cpython#107361 doesn't work with the semi broken Freebox self signed certificates.
It should fix home-assistant/core#132333
Fixes #734