startTLS: making TLS support (and dependencies) optional

This commit is contained in:
Alberto Sottile 2019-02-05 16:28:48 +01:00
parent 2219bcf4dc
commit 0c46f54510
3 changed files with 2 additions and 8 deletions

View File

@ -1,6 +1,5 @@
import ast import ast
import certifi
import collections import collections
import hashlib import hashlib
import os import os
@ -15,7 +14,6 @@ from functools import wraps
from twisted.internet.endpoints import HostnameEndpoint, wrapClientTLS from twisted.internet.endpoints import HostnameEndpoint, wrapClientTLS
from twisted.internet.protocol import ClientFactory from twisted.internet.protocol import ClientFactory
from twisted.internet.ssl import Certificate, optionsForClientTLS
from twisted.internet import reactor, task, defer, threads from twisted.internet import reactor, task, defer, threads
from twisted.application.internet import ClientService from twisted.application.internet import ClientService
@ -33,8 +31,6 @@ from syncplay.messages import getMissingStrings, getMessage
from syncplay.protocols import SyncClientProtocol from syncplay.protocols import SyncClientProtocol
from syncplay.utils import isMacOS from syncplay.utils import isMacOS
os.environ['SSL_CERT_FILE'] = certifi.where()
class SyncClientFactory(ClientFactory): class SyncClientFactory(ClientFactory):
def __init__(self, client, retry=constants.RECONNECT_RETRIES): def __init__(self, client, retry=constants.RECONNECT_RETRIES):

View File

@ -81,7 +81,7 @@ class SyncClientProtocol(JSONCommandProtocol):
self.sendTLS({"startTLS": "send"}) self.sendTLS({"startTLS": "send"})
self._client.ui.showMessage("Attempting secure connection") self._client.ui.showMessage("Attempting secure connection")
else: else:
self._client.ui.showErrorMessage("This server does not support TLS") self._client.ui.showErrorMessage("TLS is not supported")
self.sendHello() self.sendHello()
def connectionLost(self, reason): def connectionLost(self, reason):

View File

@ -5,7 +5,6 @@ import os
import random import random
import time import time
from string import Template from string import Template
from OpenSSL import crypto
from twisted.enterprise import adbapi from twisted.enterprise import adbapi
from twisted.internet import task, reactor, ssl from twisted.internet import task, reactor, ssl
@ -14,7 +13,6 @@ from twisted.internet.protocol import Factory
try: try:
from OpenSSL import crypto from OpenSSL import crypto
from twisted.internet import ssl from twisted.internet import ssl
from twisted.python.filepath import FilePath
except: except:
pass pass
@ -219,7 +217,7 @@ class SyncFactory(Factory):
self.options = contextFactory self.options = contextFactory
except Exception as e: except Exception as e:
print(e) print(e)
print("Cannot import certificates. TLS support not enabled.") print("TLS support is not enabled.")
class StatsRecorder(object): class StatsRecorder(object):