-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_ssl.py
More file actions
executable file
·82 lines (69 loc) · 2.5 KB
/
fix_ssl.py
File metadata and controls
executable file
·82 lines (69 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""
SSL Certificate Fix for Codestral CLI
Helps resolve common SSL certificate issues
"""
import ssl
import sys
import subprocess
from urllib.request import urlopen
def test_ssl_connection():
"""Test SSL connection to Codestral API"""
try:
print("🔒 Testing SSL connection to Codestral API...")
# Test the connection
with urlopen("https://codestral.mistral.ai", timeout=10) as response:
print(f"✅ SSL connection successful! Status: {response.status}")
return True
except Exception as e:
print(f"❌ SSL connection failed: {e}")
return False
def fix_certificates():
"""Try to fix certificate issues"""
print("\n🔧 Attempting to fix SSL certificates...")
fixes = [
("Upgrading certifi", ["pip3", "install", "--upgrade", "certifi"]),
("Updating CA certificates", ["pip3", "install", "--upgrade", "requests", "urllib3"]),
]
for desc, cmd in fixes:
try:
print(f" {desc}...")
subprocess.run(cmd, check=True, capture_output=True)
print(f" ✅ {desc} completed")
except subprocess.CalledProcessError as e:
print(f" ⚠️ {desc} failed: {e}")
except FileNotFoundError:
print(f" ⚠️ Command not found: {' '.join(cmd)}")
def show_workarounds():
"""Show SSL workaround options"""
print("\n🛠️ SSL Workarounds:")
print("1. Temporary SSL bypass (not recommended for production):")
print(" export PYTHONHTTPSVERIFY=0")
print(" python3 main.py")
print()
print("2. Update Python certificates (macOS):")
print(" /Applications/Python\\ 3.x/Install\\ Certificates.command")
print()
print("3. Manual certificate bundle:")
print(" pip3 install --upgrade certifi")
print(" python3 -c \"import certifi; print(certifi.where())\"")
print()
print("4. Check your firewall/proxy settings")
def main():
print("🔒 Codestral CLI - SSL Certificate Troubleshoot")
print("=" * 50)
# Test current connection
if test_ssl_connection():
print("🎉 No SSL issues detected!")
return
# Try to fix
fix_certificates()
# Test again
print("\n🔄 Testing connection after fixes...")
if test_ssl_connection():
print("🎉 SSL issues resolved!")
else:
show_workarounds()
print("\n💡 If issues persist, try the workarounds above")
if __name__ == "__main__":
main()