startTLS: making TLS support (and dependencies) optional
This commit is contained in:
parent
7dfe9d2bdb
commit
18e39b4aae
@ -1,6 +1,5 @@
|
||||
|
||||
import ast
|
||||
import certifi
|
||||
import collections
|
||||
import hashlib
|
||||
import os
|
||||
@ -15,10 +14,16 @@ from functools import wraps
|
||||
|
||||
from twisted.internet.endpoints import HostnameEndpoint, wrapClientTLS
|
||||
from twisted.internet.protocol import ClientFactory
|
||||
from twisted.internet.ssl import Certificate, optionsForClientTLS
|
||||
from twisted.internet import reactor, task, defer, threads
|
||||
from twisted.application.internet import ClientService
|
||||
|
||||
try:
|
||||
import certifi
|
||||
from twisted.internet.ssl import optionsForClientTLS
|
||||
os.environ['SSL_CERT_FILE'] = certifi.where()
|
||||
except:
|
||||
pass
|
||||
|
||||
from syncplay import utils, constants, version
|
||||
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
|
||||
PRIVACY_HIDDENFILENAME
|
||||
@ -26,8 +31,6 @@ from syncplay.messages import getMissingStrings, getMessage
|
||||
from syncplay.protocols import SyncClientProtocol
|
||||
from syncplay.utils import isMacOS
|
||||
|
||||
os.environ['SSL_CERT_FILE'] = certifi.where()
|
||||
|
||||
|
||||
class SyncClientFactory(ClientFactory):
|
||||
def __init__(self, client, retry=constants.RECONNECT_RETRIES):
|
||||
|
||||
@ -78,7 +78,7 @@ class SyncClientProtocol(JSONCommandProtocol):
|
||||
self.sendTLS({"startTLS": "send"})
|
||||
self._client.ui.showMessage("Attempting secure connection")
|
||||
else:
|
||||
self._client.ui.showErrorMessage("This server does not support TLS")
|
||||
self._client.ui.showErrorMessage("TLS is not supported")
|
||||
self.sendHello()
|
||||
|
||||
def connectionLost(self, reason):
|
||||
|
||||
@ -5,12 +5,17 @@ import os
|
||||
import random
|
||||
import time
|
||||
from string import Template
|
||||
from OpenSSL import crypto
|
||||
|
||||
from twisted.enterprise import adbapi
|
||||
from twisted.internet import task, reactor, ssl
|
||||
from twisted.internet.protocol import Factory
|
||||
|
||||
try:
|
||||
from OpenSSL import crypto
|
||||
from twisted.internet import ssl
|
||||
except:
|
||||
pass
|
||||
|
||||
import syncplay
|
||||
from syncplay import constants
|
||||
from syncplay.messages import getMessage
|
||||
@ -212,7 +217,7 @@ class SyncFactory(Factory):
|
||||
self.options = contextFactory
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Cannot import certificates. TLS support not enabled.")
|
||||
print("TLS support is not enabled.")
|
||||
|
||||
|
||||
class StatsRecorder(object):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user