Skip to content

Commit f005fbc

Browse files
feat: 禁用证书检测
1 parent 3654590 commit f005fbc

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

src/core/ota.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import json
33
import socket
4+
import ssl
45

56
import aiohttp
67

@@ -132,9 +133,17 @@ async def get_ota_config(self):
132133
payload = self.build_payload()
133134

134135
try:
136+
# 禁用SSL证书验证以支持自签名证书
137+
ssl_context = ssl.create_default_context()
138+
ssl_context.check_hostname = False
139+
ssl_context.verify_mode = ssl.CERT_NONE
140+
135141
# 使用aiohttp异步发送请求
136142
timeout = aiohttp.ClientTimeout(total=10)
137-
async with aiohttp.ClientSession(timeout=timeout) as session:
143+
connector = aiohttp.TCPConnector(ssl=ssl_context)
144+
async with aiohttp.ClientSession(
145+
timeout=timeout, connector=connector
146+
) as session:
138147
async with session.post(
139148
self.ota_version_url, headers=headers, json=payload
140149
) as response:

src/utils/common_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,3 @@ def handle_verification_code(text: str) -> None:
324324
return
325325

326326
copy_to_clipboard(code)
327-
328-
from src.utils.config_manager import ConfigManager
329-
330-
config = ConfigManager.get_instance()
331-
ota_url = config.get_config("SYSTEM_OPTIONS.NETWORK.AUTHORIZATION_URL", "")
332-
open_url(ota_url)

src/views/activation/activation_window.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,19 +428,26 @@ def _on_data_ready(self, data):
428428

429429
def _on_retry_clicked(self):
430430
"""
431-
重新激活按钮点击.
431+
跳转激活按钮点击 - 打开激活网页.
432432
"""
433-
self.logger.info("用户请求重新激活")
433+
self.logger.info("用户点击跳转激活")
434434

435-
# 检查是否已经关闭
436-
if self.is_shutdown_requested():
437-
return
438-
439-
# 重置状态
440-
self.activation_model.reset_activation_code()
441-
442-
# 重新开始初始化
443-
self.create_task(self._start_initialization(), "retry_initialization")
435+
# 从配置中获取激活URL并打开
436+
try:
437+
from src.utils.common_utils import open_url
438+
from src.utils.config_manager import ConfigManager
439+
440+
config = ConfigManager.get_instance()
441+
ota_url = config.get_config("SYSTEM_OPTIONS.NETWORK.AUTHORIZATION_URL", "")
442+
if ota_url:
443+
open_url(ota_url)
444+
self.update_status("已打开激活页面,请在浏览器中输入验证码")
445+
else:
446+
self.logger.error("未配置激活URL")
447+
self.update_status("错误: 未配置激活URL")
448+
except Exception as e:
449+
self.logger.error(f"打开激活页面失败: {e}")
450+
self.update_status(f"打开激活页面失败: {e}")
444451

445452
def _on_copy_code_clicked(self):
446453
"""

src/views/settings/components/system_options/system_options_widget.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ def get_config_data(self) -> dict:
231231
config_data = {}
232232

233233
try:
234+
# 客户端ID和设备ID
235+
client_id = self._get_text_value("client_id_edit")
236+
if client_id:
237+
config_data["SYSTEM_OPTIONS.CLIENT_ID"] = client_id
238+
239+
device_id = self._get_text_value("device_id_edit")
240+
if device_id:
241+
config_data["SYSTEM_OPTIONS.DEVICE_ID"] = device_id
242+
234243
# 系统选项 - 网络配置
235244
ota_url = self._get_text_value("ota_url_edit")
236245
if ota_url:

src/views/settings/settings_window.ui

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@
6161
<item row="0" column="1">
6262
<widget class="QLineEdit" name="client_id_edit">
6363
<property name="readOnly">
64-
<bool>true</bool>
65-
</property>
66-
<property name="styleSheet">
67-
<string>background-color: #f5f5f5;</string>
64+
<bool>false</bool>
6865
</property>
6966
</widget>
7067
</item>
@@ -81,10 +78,7 @@
8178
<item row="1" column="1">
8279
<widget class="QLineEdit" name="device_id_edit">
8380
<property name="readOnly">
84-
<bool>true</bool>
85-
</property>
86-
<property name="styleSheet">
87-
<string>background-color: #f5f5f5;</string>
81+
<bool>false</bool>
8882
</property>
8983
</widget>
9084
</item>

0 commit comments

Comments
 (0)