Fix SSL certificate validation / Fix tariff sorting for subscription renewals

This commit is contained in:
Capybara-z
2025-06-26 00:21:31 +03:00
parent 9b51324c80
commit df57d71b4c
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ async def get_tariffs(
result = await session.execute(select(Tariff).where(Tariff.id == tariff_id))
elif group_code:
result = await session.execute(
select(Tariff).where(Tariff.group_code == group_code)
select(Tariff).where(Tariff.group_code == group_code).order_by(Tariff.id)
)
else:
result = await session.execute(select(Tariff))
+5 -2
View File
@@ -41,8 +41,11 @@ async def check_tcp_connection(host: str, port: int) -> bool:
await writer.wait_closed()
return True
except ssl.SSLError as e:
err_text = str(e)
if "hostname mismatch" in err_text or "certificate is not valid for" in err_text:
return False
logger.warning(f"[SSL Error] Сертификат сервера {host} вызвал ошибку: {e}")
await notify_ssl_error(host, str(e))
await notify_ssl_error(host, err_text)
return False
except Exception:
return False
@@ -171,4 +174,4 @@ async def check_servers(session: AsyncSession):
def extract_host(api_url: str) -> str:
"""Извлекает хост из `api_url`."""
match = re.match(r"(https?://)?([^:/]+)", api_url)
return match.group(2) if match else api_url
return match.group(2) if match else api_url