本文整理汇总了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)