startTLS: find certifi.where() if embedded in a zip file
This commit is contained in:
parent
2ac6417c50
commit
9132a9ae56
@ -20,7 +20,18 @@ from twisted.application.internet import ClientService
|
|||||||
try:
|
try:
|
||||||
import certifi
|
import certifi
|
||||||
from twisted.internet.ssl import Certificate, optionsForClientTLS
|
from twisted.internet.ssl import Certificate, optionsForClientTLS
|
||||||
os.environ['SSL_CERT_FILE'] = certifi.where()
|
certPath = certifi.where()
|
||||||
|
if os.path.exists(certPath):
|
||||||
|
os.environ['SSL_CERT_FILE'] = certPath
|
||||||
|
elif 'zip' in certPath:
|
||||||
|
import tempfile
|
||||||
|
import zipfile
|
||||||
|
zipPath, memberPath = certPath.split('.zip/')
|
||||||
|
zipPath += '.zip'
|
||||||
|
archive = zipfile.ZipFile(zipPath, 'r')
|
||||||
|
tmpDir = tempfile.gettempdir()
|
||||||
|
extractedPath = archive.extract(memberPath, tmpDir)
|
||||||
|
os.environ['SSL_CERT_FILE'] = extractedPath
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -716,7 +727,7 @@ class SyncplayClient(object):
|
|||||||
port = int(port)
|
port = int(port)
|
||||||
self._endpoint = HostnameEndpoint(reactor, host, port)
|
self._endpoint = HostnameEndpoint(reactor, host, port)
|
||||||
try:
|
try:
|
||||||
caCertFP = open(certifi.where())
|
caCertFP = open(os.environ['SSL_CERT_FILE'])
|
||||||
caCertTwisted = Certificate.loadPEM(caCertFP.read())
|
caCertTwisted = Certificate.loadPEM(caCertFP.read())
|
||||||
caCertFP.close()
|
caCertFP.close()
|
||||||
self.protocolFactory.options = optionsForClientTLS(hostname=host)
|
self.protocolFactory.options = optionsForClientTLS(hostname=host)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user