Save
This commit is contained in:
@@ -175,7 +175,7 @@ class DatabaseManager:
|
|||||||
'password': server_info['password'],
|
'password': server_info['password'],
|
||||||
}
|
}
|
||||||
|
|
||||||
panel = PanelInteraction(url_base, login_data, self.logger,)
|
panel = PanelInteraction(url_base, login_data, self.logger,server_info['certificate']['data'])
|
||||||
expiry_date_iso = new_subscription.expiry_date.isoformat()
|
expiry_date_iso = new_subscription.expiry_date.isoformat()
|
||||||
|
|
||||||
# Добавляем на сервер
|
# Добавляем на сервер
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import aiohttp
|
|||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
import ssl
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
@@ -35,11 +36,26 @@ class PanelInteraction:
|
|||||||
:param is_encoded: Indicates whether the certificate is Base64-encoded.
|
:param is_encoded: Indicates whether the certificate is Base64-encoded.
|
||||||
:return: Decoded certificate content as bytes.
|
:return: Decoded certificate content as bytes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not certificate:
|
if not certificate:
|
||||||
self.logger.error("No certificate provided.")
|
self.logger.error("No certificate provided.")
|
||||||
raise ValueError("Certificate is required.")
|
raise ValueError("Certificate is required.")
|
||||||
|
try:
|
||||||
|
# Создаем SSLContext
|
||||||
|
ssl_context = ssl.create_default_context()
|
||||||
|
|
||||||
|
# Декодируем, если нужно
|
||||||
|
if is_encoded:
|
||||||
|
certificate = base64.b64decode(certificate).decode()
|
||||||
|
|
||||||
|
# Загружаем сертификат в SSLContext
|
||||||
|
ssl_context.load_verify_locations(cadata=certificate)
|
||||||
|
return ssl_context
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error while decoding certificate: {e}")
|
||||||
|
raise ValueError("Invalid certificate format or content.") from e
|
||||||
|
|
||||||
return base64.b64decode(certificate) if is_encoded else certificate.encode()
|
|
||||||
|
|
||||||
async def _ensure_logged_in(self):
|
async def _ensure_logged_in(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user