本文整理匯總了Python中twisted.internet.endpoints.SSL4ServerEndpoint方法的典型用法代碼示例。如果您正苦於以下問題:Python endpoints.SSL4ServerEndpoint方法的具體用法?Python endpoints.SSL4ServerEndpoint怎麽用?Python endpoints.SSL4ServerEndpoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.internet.endpoints
的用法示例。
在下文中一共展示了endpoints.SSL4ServerEndpoint方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createServerEndpoint
# 需要導入模塊: from twisted.internet import endpoints [as 別名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 別名]
def createServerEndpoint(self, reactor, factory, **listenArgs):
"""
Create an L{SSL4ServerEndpoint} and return the tools to verify its
behaviour.
@param factory: The thing that we expect to be passed to our
L{IStreamServerEndpoint.listen} implementation.
@param reactor: A fake L{IReactorSSL} that L{SSL4ServerEndpoint} can
call L{IReactorSSL.listenSSL} on.
@param listenArgs: Optional dictionary of arguments to
L{IReactorSSL.listenSSL}.
"""
address = IPv4Address("TCP", "0.0.0.0", 0)
return (endpoints.SSL4ServerEndpoint(reactor,
address.port,
self.serverSSLContext,
**listenArgs),
(address.port, factory, self.serverSSLContext,
listenArgs.get('backlog', 50),
listenArgs.get('interface', '')),
address)
示例2: test_ssl
# 需要導入模塊: from twisted.internet import endpoints [as 別名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 別名]
def test_ssl(self):
"""
When passed an SSL strports description, L{endpoints.serverFromString}
returns a L{SSL4ServerEndpoint} instance initialized with the values
from the string.
"""
reactor = object()
server = endpoints.serverFromString(
reactor,
"ssl:1234:backlog=12:privateKey=%s:"
"certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1"
% (escapedPEMPathName, escapedPEMPathName))
self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
self.assertIs(server._reactor, reactor)
self.assertEqual(server._port, 1234)
self.assertEqual(server._backlog, 12)
self.assertEqual(server._interface, "10.0.0.1")
self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD)
ctx = server._sslContextFactory.getContext()
self.assertIsInstance(ctx, ContextType)
示例3: test_sslWithDefaults
# 需要導入模塊: from twisted.internet import endpoints [as 別名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 別名]
def test_sslWithDefaults(self):
"""
An SSL string endpoint description with minimal arguments returns
a properly initialized L{SSL4ServerEndpoint} instance.
"""
reactor = object()
server = endpoints.serverFromString(
reactor, "ssl:4321:privateKey=%s" % (escapedPEMPathName,))
self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
self.assertIs(server._reactor, reactor)
self.assertEqual(server._port, 4321)
self.assertEqual(server._backlog, 50)
self.assertEqual(server._interface, "")
self.assertEqual(server._sslContextFactory.method, SSLv23_METHOD)
self.assertTrue(
server._sslContextFactory._options & OP_NO_SSLv3,
)
ctx = server._sslContextFactory.getContext()
self.assertIsInstance(ctx, ContextType)
# Use a class variable to ensure we use the exactly same endpoint string
# except for the chain file itself.
示例4: test_sslNoTrailingNewlinePem
# 需要導入模塊: from twisted.internet import endpoints [as 別名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 別名]
def test_sslNoTrailingNewlinePem(self):
"""
Lack of a trailing newline in key and cert .pem files should not
generate an exception.
"""
reactor = object()
server = endpoints.serverFromString(
reactor,
"ssl:1234:backlog=12:privateKey=%s:"
"certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1"
% (
escapedNoTrailingNewlineKeyPEMPathName,
escapedNoTrailingNewlineCertPEMPathName,
)
)
self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
self.assertIs(server._reactor, reactor)
self.assertEqual(server._port, 1234)
self.assertEqual(server._backlog, 12)
self.assertEqual(server._interface, "10.0.0.1")
self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD)
ctx = server._sslContextFactory.getContext()
self.assertIsInstance(ctx, ContextType)
示例5: test_ssl
# 需要導入模塊: from twisted.internet import endpoints [as 別名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 別名]
def test_ssl(self):
"""
When passed an SSL strports description, L{endpoints.serverFromString}
returns a L{SSL4ServerEndpoint} instance initialized with the values
from the string.
"""
reactor = object()
server = endpoints.serverFromString(
reactor,
"ssl:1234:backlog=12:privateKey=%s:"
"certKey=%s:interface=10.0.0.1" % (escapedPEMPathName,
escapedPEMPathName))
self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
self.assertIdentical(server._reactor, reactor)
self.assertEquals(server._port, 1234)
self.assertEquals(server._backlog, 12)
self.assertEquals(server._interface, "10.0.0.1")
ctx = server._sslContextFactory.getContext()
self.assertIsInstance(ctx, ContextType)