Skip to content

Commit

Permalink
more work on time hinting 5
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansev committed Nov 8, 2023
1 parent cdb1a18 commit 89108ce
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions alienpy/connect_ssl.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
'''alienpy:: SSL and certificate tooling'''
"""alienpy:: SSL and certificate tooling"""

import sys
import os
import logging
import uuid
import traceback
import datetime

try:
import ssl
except Exception:
print("Python ssl module could not be imported! Make sure you can do:\npython3 -c 'import ssl'", file = sys.stderr, flush = True)
sys.exit(1)

import tempfile
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Expand All @@ -21,15 +15,20 @@
except Exception:
print("cryptography module could not be imported! Make sure you can do:\npython3 -c 'import cryptography'", file = sys.stderr, flush = True)
sys.exit(1)

try:
import ssl
except Exception:
print("Python ssl module could not be imported! Make sure you can do:\npython3 -c 'import ssl'", file = sys.stderr, flush = True)
sys.exit(1)
try:
import OpenSSL
except Exception:
print("OpenSSL module could not be loaded", file = sys.stderr, flush = True)
sys.exit(1)

## GLOBALS
from .global_vars import * # nosec PYL-W0614
from .data_structs import CertsInfo, RET
from .global_vars import AlienSessionInfo, COLORS, DEBUG, DEBUG_FILE, TOKENCERT_NAME, TOKENKEY_NAME, USERCERT_NAME, USERKEY_NAME, USER_HOME
from .tools_nowb import PrintColor, path_readable
from .setup_logging import print_err

Expand Down Expand Up @@ -174,7 +173,6 @@ def renewCredFilesInfo() -> CertsInfo:

def create_ssl_context(use_usercert: bool = False, user_cert: str = '', user_key: str = '', token_cert: str = '', token_key: str = '') -> ssl.SSLContext:
"""Create SSL context using either the default names for user certificate and token certificate or X509_USER_{CERT,KEY} JALIEN_TOKEN_{CERT,KEY} environment variables"""

if use_usercert or not token_cert:
if AlienSessionInfo: AlienSessionInfo['use_usercert'] = True
cert, key = user_cert, user_key
Expand Down

0 comments on commit 89108ce

Please sign in to comment.