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


Python Certificate.load方法代码示例

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


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

示例1: from_path

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import load [as 别名]
    def from_path(cls, path):
        """
        :param FilePath path: Directory where private key and certificate are
            stored.
        """
        if not path.isdir():
            raise PathError(
                b"Path {path} is not a directory.".format(path=path.path)
            )

        certPath = path.child(certificate_filename)
        keyPath = path.child(key_filename)

        if not certPath.isfile():
            raise PathError(
                b"Certificate file {path} does not exist.".format(
                    path=certPath.path)
            )

        if not keyPath.isfile():
            raise PathError(
                b"Private key file {path} does not exist.".format(
                    path=keyPath.path)
            )

        try:
            certFile = certPath.open()
        except IOError:
            raise PathError(
                (b"Certificate file {path} could not be opened. "
                 b"Check file permissions.").format(
                    path=certPath.path)
            )

        try:
            keyFile = keyPath.open()
        except IOError:
            raise PathError(
                (b"Private key file {path} could not be opened. "
                 b"Check file permissions.").format(
                    path=keyPath.path)
            )

        certificate = Certificate.load(
            certFile.read(), format=crypto.FILETYPE_PEM)
        keypair = FlockerKeyPair(
            keypair=KeyPair.load(keyFile.read(), format=crypto.FILETYPE_PEM)
        )

        return cls(path=path, certificate=certificate, keypair=keypair)
开发者ID:ALSEDLAH,项目名称:flocker,代码行数:52,代码来源:_ca.py

示例2: initWithCoder_

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import load [as 别名]
 def initWithCoder_(self, coder):
     """
     Initialize model object with the content from the L{NSCoder}.
     """
     self = NSObject.init(self)
     if self is None:
         return None
     self.account = None
     self.cert = None
     self.name = coder.decodeObjectForKey_("name")
     self.email = coder.decodeObjectForKey_("email")
     certBytes, lenBytes = coder.decodeBytesForKey_returnedLength_(
         "cert", None
         )
     print lenBytes
     if lenBytes:
         self.cert = Certificate.load(certBytes)
     return self
开发者ID:jrydberg,项目名称:friendly,代码行数:20,代码来源:model.py

示例3: load_certificate_file

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import load [as 别名]
def load_certificate_file(path):
    """
    Load a certificate from a specified path.

    :param FilePath path: Absolute path to certificate file.

    :return: A ``Certificate`` instance representing the parsed
        certificate data.
    """
    try:
        certificate_file = path.open()
    except IOError as e:
        code, failure = e
        raise PathError(
            b"Certificate file could not be opened.",
            e.filename, code, failure
        )
    certificate = Certificate.load(
        certificate_file.read(), format=crypto.FILETYPE_PEM)
    return certificate
开发者ID:332054781,项目名称:flocker,代码行数:22,代码来源:_ca.py

示例4: load_certificate_from_path

# 需要导入模块: from twisted.internet.ssl import Certificate [as 别名]
# 或者: from twisted.internet.ssl.Certificate import load [as 别名]
def load_certificate_from_path(path, key_filename, cert_filename):
    """
    Load a certificate and keypair from a specified path.

    :param FilePath path: Directory where certificate and key files
        are stored.
    :param bytes key_filename: The file name of the private key.
    :param bytes cert_filename: The file name of the certificate.

    :return: A ``tuple`` containing the loaded key and certificate
        instances.
    """
    certPath = path.child(cert_filename)
    keyPath = path.child(key_filename)

    try:
        certFile = certPath.open()
    except IOError as e:
        code, failure = e
        raise PathError(
            b"Certificate file could not be opened.",
            e.filename, code, failure
        )

    try:
        keyFile = keyPath.open()
    except IOError as e:
        code, failure = e
        raise PathError(
            b"Private key file could not be opened.",
            e.filename, code, failure
        )

    certificate = Certificate.load(
        certFile.read(), format=crypto.FILETYPE_PEM)
    keypair = ComparableKeyPair(
        keypair=KeyPair.load(keyFile.read(), format=crypto.FILETYPE_PEM)
    )
    return (keypair, certificate)
开发者ID:gideonmay,项目名称:flocker,代码行数:41,代码来源:_ca.py


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