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


Python PrivateCertificate.fromCertificateAndKeyPair方法代码示例

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


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

示例1: clientCertFor

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
def clientCertFor(name):
    signingCert = getCAPrivateCert()
    clientKey = KeyPair.generate(size=4096)
    csr = clientKey.requestObject(DN(CN=name), "sha1")
    clientCert = signingCert.signRequestObject(
        csr, serialNumber=1, digestAlgorithm="sha1")
    return PrivateCertificate.fromCertificateAndKeyPair(clientCert, clientKey)
开发者ID:damouse,项目名称:pdservertemp,代码行数:9,代码来源:newcert.py

示例2: clientCertFor

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
def clientCertFor(p_name):
    l_signingCert = getCAPrivateCert()
    l_clientKey = KeyPair.generate(size = 4096)
    l_csr = l_clientKey.requestObject(DN(CN = p_name), "sha1")
    l_clientCert = l_signingCert.signRequestObject(
        l_csr, serialNumber = 1, digestAlgorithm = "sha1")
    return PrivateCertificate.fromCertificateAndKeyPair(l_clientCert, l_clientKey)
开发者ID:DBrianKimmel,项目名称:PyHouse,代码行数:9,代码来源:newcert.py

示例3: private_certificate

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
    def private_certificate(self):
        """
        Combine private key and certificate into a ``PrivateCertificate``.

        :return: ``PrivateCertificate`` instance.
        """
        return PrivateCertificate.fromCertificateAndKeyPair(
            self.certificate, self.keypair.keypair)
开发者ID:gideonmay,项目名称:flocker,代码行数:10,代码来源:_ca.py

示例4: _create_tls_client_context

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
def _create_tls_client_context(config, cbdir, log):
    """
    Create a CertificateOptions object for use with TLS listening endpoints.
    """
    # server hostname: The expected name of the remote host.
    hostname = config['hostname']

    # explicit trust (certificate) root
    ca_certs = None
    if 'ca_certificates' in config:
        log.info("TLS client using explicit trust ({cnt_certs} certificates)", cnt_certs=len(config['ca_certificates']))
        ca_certs = []
        for cert_fname in [os.path.abspath(os.path.join(cbdir, x)) for x in (config['ca_certificates'])]:
            cert = crypto.load_certificate(
                crypto.FILETYPE_PEM,
                six.u(open(cert_fname, 'r').read())
            )
            log.info("TLS client trust root CA certificate loaded from '{fname}'", fname=cert_fname)
            ca_certs.append(cert)
        ca_certs = OpenSSLCertificateAuthorities(ca_certs)
    else:
        log.info("TLS client using platform trust")

    # client key/cert to use
    client_cert = None
    if 'key' in config:
        if 'certificate' not in config:
            raise Exception('TLS client key present, but certificate missing')

        key_fname = os.path.abspath(os.path.join(cbdir, config['key']))
        with open(key_fname, 'r') as f:
            private_key = KeyPair.load(f.read(), format=crypto.FILETYPE_PEM)
            log.info("Loaded client TLS key from '{key_fname}'", key_fname=key_fname)

        cert_fname = os.path.abspath(os.path.join(cbdir, config['certificate']))
        with open(cert_fname, 'r') as f:
            cert = Certificate.loadPEM(f.read(),)
            log.info("Loaded client TLS certificate from '{cert_fname}' (cn='{cert_cn}', sha256={cert_sha256}..)",
                     cert_fname=cert_fname,
                     cert_cn=cert.getSubject().CN,
                     cert_sha256=cert.digest('sha256')[:12])

        client_cert = PrivateCertificate.fromCertificateAndKeyPair(cert, private_key)
    else:
        if 'certificate' in config:
            log.warn('TLS client certificate present, but key is missing')

    # create TLS client context
    ctx = optionsForClientTLS(hostname, trustRoot=ca_certs, clientCertificate=client_cert)

    return ctx
开发者ID:FirefighterBlu3,项目名称:crossbar,代码行数:53,代码来源:endpoint.py

示例5: actualTest

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
        def actualTest(result):
            ponged = defer.Deferred()
            signer = self.serverService2.certificateStorage.getPrivateCertificate(
                self.fromDomain).privateKey
            req = signer.requestObject(DistinguishedName(commonName=self.toDomain))
            sreq = signer.signRequestObject(
                DistinguishedName(commonName=self.fromDomain), req, 12345)
            selfSignedLie = PrivateCertificate.fromCertificateAndKeyPair(
                sreq, signer)
            self.serverService2.connectQ2Q(self.fromAddress,
                                          self.toAddress,
                                          'pony',
                                          OneTrickPonyClientFactory(ponged),
                                          selfSignedLie,
                                          fakeFromDomain=self.toDomain).addErrback(
                lambda e: e.trap(q2q.VerifyError))

            return self.assertFailure(ponged, q2q.VerifyError)
开发者ID:exarkun,项目名称:vertex,代码行数:20,代码来源:test_q2q.py

示例6: __init__

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
 def __init__(self, publicPath, privatePath, csrPath, key, cert, issuer):
     self.publicPath = publicPath
     self.privatePath = privatePath
     self.csrPath = csrPath
     self.cert = PrivateCertificate.fromCertificateAndKeyPair(cert, key)
     self.issuer = issuer
开发者ID:tomprince,项目名称:deed,代码行数:8,代码来源:authority.py

示例7: pems

# 需要导入模块: from twisted.internet.ssl import PrivateCertificate [as 别名]
# 或者: from twisted.internet.ssl.PrivateCertificate import fromCertificateAndKeyPair [as 别名]
 def pems():
     for i in count():
         key = KeyPair.generate()
         cert = key.selfSignedCert(i, commonName=u"lae_automation testing")
         pem = PrivateCertificate.fromCertificateAndKeyPair(cert, key).dumpPEM()
         yield pem.decode("ascii")
开发者ID:LeastAuthority,项目名称:leastauthority.com,代码行数:8,代码来源:strategies.py


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