本文整理汇总了Python中twisted.internet.ssl.Certificate.peerFromTransport方法的典型用法代码示例。如果您正苦于以下问题:Python Certificate.peerFromTransport方法的具体用法?Python Certificate.peerFromTransport怎么用?Python Certificate.peerFromTransport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.ssl.Certificate
的用法示例。
在下文中一共展示了Certificate.peerFromTransport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remote_login
# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
def remote_login(self, client):
# print 'Remote login!'
peerCertificate = Certificate.peerFromTransport(self.broker.transport)
pdid = peerCertificate.getSubject().commonName.decode('utf-8')
avatar, logout = yield self.portal.login(pdid, client)
avatar = pb.AsReferenceable(avatar, "perspective")
# Formerly in _cbLogin, moved here to make the deferred chain cleaner
puid = avatar.processUniqueID()
# only call logout once, whether the connection is dropped (disconnect)
# or a logout occurs (cleanup), and be careful to drop the reference to
# it in either case
logout = [logout]
def maybeLogout():
if not logout:
return
fn = logout[0]
del logout[0]
fn()
self.broker._localCleanup[puid] = maybeLogout
self.broker.notifyOnDisconnect(maybeLogout)
defer.returnValue(avatar)
示例2: startTLS
# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
def startTLS(self, certificate, *verifyAuthorities):
if self.hostCertificate is None:
self.hostCertificate = certificate
self._justStartedTLS = True
self.transport.startTLS(certificate.options(*verifyAuthorities))
stlsb = self._startingTLSBuffer
if stlsb is not None:
self._startingTLSBuffer = None
for box in stlsb:
self.sendPacket(box)
else:
raise RuntimeError(
"Previously authenticated connection between %s and %s "
"is trying to re-establish as %s" % (
self.hostCertificate,
Certificate.peerFromTransport(self.transport),
(certificate, verifyAuthorities)))
示例3: login2
# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
def login2(self, portal):
self.portal = portal
# Returns a _RifflePortalWrapper remote reference. Set a timeout
# in case the connection is down
self.setTimeout(TIMEOUT)
root = yield self.getRootObject()
# Reset the timeout, indicating we've made the connection and are done waiting
self.setTimeout(None)
# Extract the name from credentials
peerCertificate = Certificate.peerFromTransport(self._broker.transport)
pdid = peerCertificate.getSubject().commonName.decode('utf-8')
# Returns the server's avatar based on the client's interpretation
# 'other' is the other end of the connection.
other = self.portal.partialLogin(pdid)
# Convert to remote referentiable for transmission
referencibleOther = pb.AsReferenceable(other, "perspective")
# Here is the problem. The login call triggers the init call, and that
# starts the chain of riffle callbacks, but this object won't be back in time by then!
# Avatar is the remotely described API object
avatar = yield root.callRemote('login', referencibleOther)
other.remote = Levy(avatar)
# This is absolutely not needed. The point of this method is to registers
# the new connections with the portal, but we already have all the pieces.
# a, b = yield self.portal.login(pdid, avatar)
# tttteeeemmmpppppoooorrraaaarrryyy
realm = self.portal.findRealm(pdid)
realm.attach(other, avatar)
avatar.callRemote('handshake')
other.perspective_handshake()
defer.returnValue(avatar)
示例4: dataReceived
# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import peerFromTransport [as 别名]
def dataReceived(self, data):
peerCertificate = Certificate.peerFromTransport(self.transport)
print(peerCertificate.getSubject().commonName.decode('utf-8'))
self.transport.loseConnection()