当前位置: 首页>>代码示例>>Python>>正文


Python PrivateCertificate._setPrivateKey方法代码示例

本文整理汇总了Python中twisted.internet.ssl.PrivateCertificate._setPrivateKey方法的典型用法代码示例。如果您正苦于以下问题:Python PrivateCertificate._setPrivateKey方法的具体用法?Python PrivateCertificate._setPrivateKey怎么用?Python PrivateCertificate._setPrivateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.ssl.PrivateCertificate的用法示例。


在下文中一共展示了PrivateCertificate._setPrivateKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ssl

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import _setPrivateKey [as 别名]
 def test_ssl(self):
     """
     When passed an SSL strports description, L{clientFromString} returns a
     L{SSL4ClientEndpoint} instance initialized with the values from the
     string.
     """
     reactor = object()
     client = endpoints.clientFromString(
         reactor,
         "ssl:host=example.net:port=4321:privateKey=%s:"
         "certKey=%s:bindAddress=10.0.0.3:timeout=3:caCertsDir=%s" %
          (escapedPEMPathName,
           escapedPEMPathName,
           escapedCAsPathName))
     self.assertIsInstance(client, endpoints.SSL4ClientEndpoint)
     self.assertIdentical(client._reactor, reactor)
     self.assertEqual(client._host, "example.net")
     self.assertEqual(client._port, 4321)
     self.assertEqual(client._timeout, 3)
     self.assertEqual(client._bindAddress, "10.0.0.3")
     certOptions = client._sslContextFactory
     self.assertIsInstance(certOptions, CertificateOptions)
     ctx = certOptions.getContext()
     self.assertIsInstance(ctx, ContextType)
     self.assertEqual(Certificate(certOptions.certificate),
                       testCertificate)
     privateCert = PrivateCertificate(certOptions.certificate)
     privateCert._setPrivateKey(KeyPair(certOptions.privateKey))
     self.assertEqual(privateCert, testPrivateCertificate)
     expectedCerts = [
         Certificate.loadPEM(x.getContent()) for x in
             [casPath.child("thing1.pem"), casPath.child("thing2.pem")]
         if x.basename().lower().endswith('.pem')
     ]
     self.assertEqual(sorted((Certificate(x) for x in certOptions.caCerts),
                             key=lambda cert: cert.digest()),
                      sorted(expectedCerts,
                             key=lambda cert: cert.digest()))
开发者ID:anrysev,项目名称:twisted,代码行数:40,代码来源:test_endpoints.py


注:本文中的twisted.internet.ssl.PrivateCertificate._setPrivateKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。