Tkd-Alex / Twitch-Channel-Points-Miner-v2

A simple script that will watch a stream for you and earn the channel points.
GNU General Public License v3.0
1.22k stars 679 forks source link

WebSocket error: [SSL: CERTIFICATE_VERIFY_FAILED] #159

Open 13MrBlackCat13 opened 3 years ago

13MrBlackCat13 commented 3 years ago

My settings Streamer("secret", settings=StreamerSettings(make_predictions=True , follow_raid=False , claim_drops=True , watch_streak=True , bet=BetSettings(strategy=Strategy.SMART , percentage=5 , stealth_mode=True, percentage_gap=20 , max_points=100000 , filter_condition=FilterCondition(by=OutcomeKeys.TOTAL_USERS, where=Condition.LTE, value=800 ) ) )), Streamer("secret", settings=StreamerSettings(make_predictions=True , follow_raid=True , claim_drops=True , watch_streak=True , bet=BetSettings(strategy=Strategy.SMART , percentage=5 , stealth_mode=False, percentage_gap=30 , max_points=100000 , filter_condition=FilterCondition(by=OutcomeKeys.ODDS, where=Condition.LT, value=300 ) ) )),

Desktop (please complete the following information):

25/04/21 22:17:22 - ERROR - [on_error]: #0 - WebSocket error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125) 25/04/21 22:17:22 - INFO - [on_close]: #0 - WebSocket closed 25/04/21 22:17:22 - INFO - [handle_reconnection]: #0 - Reconnecting to Twitch PubSub server in ~60 seconds 25/04/21 22:17:52 - ERROR - [on_error]: #0 - WebSocket error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125) 25/04/21 22:17:52 - INFO - [on_close]: #0 - WebSocket closed

Rakambda commented 3 years ago

Twitch changed their certificate 5 days ago (20/04). Maybe can be related to that.

Maybe the websocket library caches the certificate until its end of validity. If Twitch changed it before it, you may have an old certificate in cache. That's just a supposition though.

Tkd-Alex commented 3 years ago

Dammit, It's probable that @RakSrinaNa say right. Currently, I don't have too much time, and I've also shutdown my Raspberry with the script running.

Anyone else has the same problem? You could also try to do pip install -r requirements.txt --upgrade

Rakambda commented 3 years ago

You can disable SSL verification like this:

Index: TwitchChannelPointsMiner/classes/WebSocketsPool.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/TwitchChannelPointsMiner/classes/WebSocketsPool.py b/TwitchChannelPointsMiner/classes/WebSocketsPool.py
--- a/TwitchChannelPointsMiner/classes/WebSocketsPool.py    (revision 4d6d0f0afb8e2e986e6bf39b45e5cc9ef314d295)
+++ b/TwitchChannelPointsMiner/classes/WebSocketsPool.py    (date 1619385799247)
@@ -2,6 +2,7 @@
 import logging
 import random
 import time
+import ssl
 from threading import Thread, Timer

 from dateutil import parser
@@ -67,7 +68,7 @@
         )

     def __start(self, index):
-        thread_ws = Thread(target=lambda: self.ws[index].run_forever())
+        thread_ws = Thread(target=lambda: self.ws[index].run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}))
         thread_ws.daemon = True
         thread_ws.name = f"WebSocket #{self.ws[index].index}"
         thread_ws.start()

Though I wouldn't really recommend it. Would be better to find how to clear out the websocket's cache of certificates.

Rakambda commented 3 years ago

Maybe another thing you can try is clearing your DNS cache. Maybe that'd force it to get back the IP on a DNS and the certificate along it? (stop the script before, run the command, and start it again)

Windows: ipconfig /flushdns Linux: sudo systemd-resolve --flush-caches

anger commented 3 years ago

Maybe another thing you can try is clearing your DNS cache. Maybe that'd force it to get back the IP on a DNS and the certificate along it? (stop the script before, run the command, and start it again)

Windows: ipconfig /flushdns Linux: sudo systemd-resolve --flush-caches

Dammit, It's probable that @RakSrinaNa say right. Currently, I don't have too much time, and I've also shutdown my Raspberry with the script running.

Anyone else has the same problem? You could also try to do pip install -r requirements.txt --upgrade

Both of these do not work for me, still the same error.

Emmes420 commented 3 years ago

You can disable SSL verification like this:

Index: TwitchChannelPointsMiner/classes/WebSocketsPool.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/TwitchChannelPointsMiner/classes/WebSocketsPool.py b/TwitchChannelPointsMiner/classes/WebSocketsPool.py
--- a/TwitchChannelPointsMiner/classes/WebSocketsPool.py  (revision 4d6d0f0afb8e2e986e6bf39b45e5cc9ef314d295)
+++ b/TwitchChannelPointsMiner/classes/WebSocketsPool.py  (date 1619385799247)
@@ -2,6 +2,7 @@
 import logging
 import random
 import time
+import ssl
 from threading import Thread, Timer

 from dateutil import parser
@@ -67,7 +68,7 @@
         )

     def __start(self, index):
-        thread_ws = Thread(target=lambda: self.ws[index].run_forever())
+        thread_ws = Thread(target=lambda: self.ws[index].run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}))
         thread_ws.daemon = True
         thread_ws.name = f"WebSocket #{self.ws[index].index}"
         thread_ws.start()

Though I wouldn't really recommend it. Would be better to find how to clear out the websocket's cache of certificates.

wich file name do I change that

smurygin commented 3 years ago

Faced with the same problem on mac os.

First, disabling SSL is a VERY BAD idea. If you used the fix above, then revert all the changes!

Solution:

  1. Stop bot
  2. Go Finder -> Applications -> Python
  3. Run "Install Certificates.command"
  4. Run bot