checking encryption, fixing module calling
This commit is contained in:
@@ -6,10 +6,14 @@ import ssl
|
||||
import os
|
||||
import logging
|
||||
from OpenSSL import crypto
|
||||
from .config import TLS_CERT_FILE, TLS_KEY_FILE
|
||||
from email_server.config import TLS_CERT_FILE, TLS_KEY_FILE
|
||||
from email_server.tool_box import ensure_folder_exists
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
ensure_folder_exists(TLS_CERT_FILE)
|
||||
ensure_folder_exists(TLS_KEY_FILE)
|
||||
|
||||
def generate_self_signed_cert():
|
||||
"""Generate self-signed SSL certificate if it doesn't exist."""
|
||||
if os.path.exists(TLS_CERT_FILE) and os.path.exists(TLS_KEY_FILE):
|
||||
@@ -26,6 +30,8 @@ def generate_self_signed_cert():
|
||||
# Generate certificate
|
||||
cert = crypto.X509()
|
||||
cert.get_subject().CN = 'localhost'
|
||||
cert.get_subject().O = 'PyMTA Server'
|
||||
cert.get_subject().C = 'GB'
|
||||
cert.set_serial_number(1000)
|
||||
cert.gmtime_adj_notBefore(0)
|
||||
cert.gmtime_adj_notAfter(365 * 24 * 60 * 60) # Valid for 1 year
|
||||
|
||||
Reference in New Issue
Block a user