Save
This commit is contained in:
@@ -2,6 +2,7 @@ import aiohttp
|
||||
import uuid
|
||||
import json
|
||||
import base64
|
||||
import ssl
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
@@ -35,11 +36,26 @@ class PanelInteraction:
|
||||
:param is_encoded: Indicates whether the certificate is Base64-encoded.
|
||||
:return: Decoded certificate content as bytes.
|
||||
"""
|
||||
|
||||
if not certificate:
|
||||
self.logger.error("No certificate provided.")
|
||||
raise ValueError("Certificate is required.")
|
||||
try:
|
||||
# Создаем SSLContext
|
||||
ssl_context = ssl.create_default_context()
|
||||
|
||||
return base64.b64decode(certificate) if is_encoded else certificate.encode()
|
||||
# Декодируем, если нужно
|
||||
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
|
||||
|
||||
|
||||
async def _ensure_logged_in(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user