Yonsm / MiService

XiaoMi Cloud Service for mi.com
MIT License
634 stars 188 forks source link

[SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] #22

Open guogzhao opened 1 year ago

guogzhao commented 1 year ago

➜ MiService-main python micli.py list Exception on login =xxxxxx@gmail.com: Cannot connect to host account.xiaomi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection transport, protocol = await self._create_connection_transport( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport await waiter File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 534, in data_received ssldata, appdata = self._sslpipe.feed_ssldata(data) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 975, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/xxxxxx/Downloads/MiService-main/miservice/miaccount.py", line 56, in login resp = await self._serviceLogin(f'serviceLogin?sid={sid}&_json=true') File "/Users/xxxxxx/Downloads/MiService-main/miservice/miaccount.py", line 94, in _serviceLogin async with self.session.request('GET' if data is None else 'POST', url, data=data, cookies=cookies, headers=headers) as r: File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection raise last_exc File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host account.xiaomi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] Error https://api.io.mi.com/app/home/device_list: Login failed

guogzhao commented 1 year ago

证书验证失败?这是什么情况呀?

unomede commented 1 year ago

I have the same error, perhaps the api of our account is banned by Xiaomi ?

guogzhao commented 1 year ago

I have the same error, perhaps the api of our account is banned by Xiaomi ?

I don't really think so. Because I can log in account.xiaomi.com with my Xiaomi ID and password. I am also very troubled. What is going on?

unomede commented 1 year ago

I have solved the problem. add a parameter "ssl = False " to the following code in miaccount.py.

async with self.session.request( "GET" if data is None else "POST", url, data=data, cookies=cookies, headers=headers, ssl = False ) as r

wangbeishan commented 1 year ago

I have solved the problem. add a parameter "ssl = False " to the following code in miaccount.py.

async with self.session.request( "GET" if data is None else "POST", url, data=data, cookies=cookies, headers=headers, ssl = False ) as r

I change 'ssl=false', but can`t work, still the same error. I need help

unomede commented 1 year ago

you should change it in the path where it shows the error. The path is in cmd error infomation. 

------------------ 原始邮件 ------------------ 发件人: "Yonsm/MiService" @.>; 发送时间: 2023年3月13日(星期一) 上午10:04 @.>; @.**@.>; 主题: Re: [Yonsm/MiService] [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] (Issue #22)

I have solved the problem. add a parameter "ssl = False " to the following code in miaccount.py.

async with self.session.request( "GET" if data is None else "POST", url, data=data, cookies=cookies, headers=headers, ssl = False ) as r

I change 'ssl=false', but can`t work, still the same error. I need help

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

wangbeishan commented 1 year ago

you should change it in the path where it shows the error. The path is in cmd error infomation. 

In which to modify? The error is the path of the python library. The follow is the error message:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host sts.api.io.mi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')] Error https://api.io.mi.com/app/home/device_list: Login failed

unomede commented 1 year ago

I guess it would be 

"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/MiService/miservice/miaccount.py"

------------------ 原始邮件 ------------------ 发件人: "Yonsm/MiService" @.>; 发送时间: 2023年3月13日(星期一) 上午10:30 @.>; @.**@.>; 主题: Re: [Yonsm/MiService] [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] (Issue #22)

you should change it in the path where it shows the error. The path is in cmd error infomation. 

In which to modify? The error is the path of the python library. The follow is the error message:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host sts.api.io.mi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')] Error https://api.io.mi.com/app/home/device_list: Login failed

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

wangbeishan commented 1 year ago

I guess it would be  "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/MiService/miservice/miaccount.py" ------------------ 原始邮件 ------------------ 发件人: "Yonsm/MiService" @.>; 发送时间: 2023年3月13日(星期一) 上午10:30 @.>; @.**@.>; 主题: Re: [Yonsm/MiService] [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] (Issue #22) you should change it in the path where it shows the error. The path is in cmd error infomation.  In which to modify? The error is the path of the python library. The follow is the error message: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host sts.api.io.mi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')] Error https://api.io.mi.com/app/home/device_list: Login failed — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

But this file is a library of Python, I can’t modify it.

unomede commented 1 year ago

But I have changed it and got success.

wangbeishan commented 1 year ago

I guess it would be  "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/MiService/miservice/miaccount.py" ------------------ 原始邮件 ------------------ 发件人: "Yonsm/MiService" @.**>; 发送时间: 2023年3月13日(星期一) 上午10:30 @.**>; @.**@.**>; 主题: Re: [Yonsm/MiService] [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')] (Issue #22) you should change it in the path where it shows the error. The path is in cmd error infomation.  In which to modify? The error is the path of the python library. The follow is the error message: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host sts.api.io.mi.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')] Error https://api.io.mi.com/app/home/device_list: Login failed — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

But this file is a library of Python, I can’t modify it.

This problem has been resolved. It turned out to be an issue with the Python version. After downgrading from 3.11.2 to 3.9, it was successful. Thank you.