Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SESSION_SSL=NEVER #137

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tnz/tnz.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, name=None):
self.__secure = False
self.__cert_verified = False
self.__start_tls_hostname = None
self.__start_tls_completed = False
self.__host_verified = False
self._event = None
self.__loop = None
Expand Down Expand Up @@ -2144,7 +2145,11 @@ def _process(self, data):
self.send_do(25, buffer=True)

elif data[2] == 46: # START_TLS
if not hasattr(self.__loop, "start_tls"):
if os.environ.get("SESSION_SSL") == "NEVER":
self.__log_info("START_TLS SESSION_SSL=NEVER.")
self.send_wont(data[2], buffer=True)

elif not hasattr(self.__loop, "start_tls"):
self._log_warn("START_TLS unsupported.")
self._log_warn("Python >= 3.7 required")
self.send_wont(data[2], buffer=True)
Expand Down Expand Up @@ -4502,6 +4507,7 @@ async def __start_tls(self, context):

else:
self._transport = transport
self.__start_tls_completed = True
self.__secure = True
if context.verify_mode == ssl.CERT_REQUIRED:
self.__cert_verified = True
Expand Down Expand Up @@ -4764,6 +4770,12 @@ def secure(self):
"""
return self.__secure

@property
def start_tls_completed(self):
"""Bool indicating if start_tls completed.
"""
return self.__start_tls_completed

@property
def tn3270(self):
"""Bool indicating if NOT NVT mode.
Expand Down
10 changes: 8 additions & 2 deletions tnz/zti.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,19 @@ def do_session(self, arg):
elif tns.cert_verified:
verify = "cert"

session_ssl = int(not tns.start_tls_completed)
if verify:
if not session_ssl:
print(f" SESSION_SSL=0")

print(f" SESSION_SSL_VERIFY={verify}")
else:
print(f" SESSION_SSL=1")
if session_ssl:
print(f" SESSION_SSL=1")

print(f" SESSION_SSL_VERIFY=none")
else:
print(f" SESSION_SSL=0")
print(f" SESSION_SSL=NEVER")

print(f" SESSION_TN_ENHANCED={tns.tn3270e:d}")
print(f" SESSION_DEVICE_TYPE={tns.terminal_type}")
Expand Down