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


Python _helpers._parse_pem_key方法代码示例

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


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

示例1: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password=b'notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PKCS12 or PEM format.
            password: string, password for the private key file.

        Returns:
            Signer instance.

        Raises:
            OpenSSL.crypto.Error if the key can't be parsed.
        """
        key = _to_bytes(key)
        parsed_pem_key = _parse_pem_key(key)
        if parsed_pem_key:
            pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)
        else:
            password = _to_bytes(password, encoding='utf-8')
            pkey = crypto.load_pkcs12(key, password).get_privatekey()
        return OpenSSLSigner(pkey) 
开发者ID:0x0ece,项目名称:oscars2016,代码行数:23,代码来源:_openssl_crypt.py

示例2: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password='notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PEM format.
            password: string, password for private key file. Unused for PEM
                      files.

        Returns:
            Signer instance.

        Raises:
            NotImplementedError if the key isn't in PEM format.
        """
        parsed_pem_key = _parse_pem_key(_to_bytes(key))
        if parsed_pem_key:
            pkey = RSA.importKey(parsed_pem_key)
        else:
            raise NotImplementedError(
                'PKCS12 format is not supported by the PyCrypto library. '
                'Try converting to a "PEM" '
                '(openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > '
                'privatekey.pem) '
                'or using PyOpenSSL if native code is an option.')
        return PyCryptoSigner(pkey) 
开发者ID:0x0ece,项目名称:oscars2016,代码行数:27,代码来源:_pycrypto_crypt.py

示例3: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password=b'notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PKCS12 or PEM format.
            password: string, password for the private key file.

        Returns:
            Signer instance.

        Raises:
            OpenSSL.crypto.Error if the key can't be parsed.
        """
        key = _helpers._to_bytes(key)
        parsed_pem_key = _helpers._parse_pem_key(key)
        if parsed_pem_key:
            pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)
        else:
            password = _helpers._to_bytes(password, encoding='utf-8')
            pkey = crypto.load_pkcs12(key, password).get_privatekey()
        return OpenSSLSigner(pkey) 
开发者ID:taers232c,项目名称:GAMADV-XTD,代码行数:23,代码来源:_openssl_crypt.py

示例4: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password='notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PEM format.
            password: string, password for private key file. Unused for PEM
                      files.

        Returns:
            Signer instance.

        Raises:
            NotImplementedError if the key isn't in PEM format.
        """
        parsed_pem_key = _helpers._parse_pem_key(_helpers._to_bytes(key))
        if parsed_pem_key:
            pkey = RSA.importKey(parsed_pem_key)
        else:
            raise NotImplementedError(
                'No key in PEM format was detected. This implementation '
                'can only use the PyCrypto library for keys in PEM '
                'format.')
        return PyCryptoSigner(pkey) 
开发者ID:taers232c,项目名称:GAMADV-XTD,代码行数:25,代码来源:_pycrypto_crypt.py

示例5: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password='notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PEM format.
            password: string, password for private key file. Unused for PEM
                      files.

        Returns:
            Signer instance.

        Raises:
            NotImplementedError if the key isn't in PEM format.
        """
        parsed_pem_key = _parse_pem_key(_to_bytes(key))
        if parsed_pem_key:
            pkey = RSA.importKey(parsed_pem_key)
        else:
            raise NotImplementedError(
                'No key in PEM format was detected. This implementation '
                'can only use the PyCrypto library for keys in PEM '
                'format.')
        return PyCryptoSigner(pkey) 
开发者ID:Servir-Mekong,项目名称:ecodash,代码行数:25,代码来源:_pycrypto_crypt.py

示例6: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password=b'notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PKCS12 or PEM format.
            password: string, password for the private key file.

        Returns:
            Signer instance.

        Raises:
            OpenSSL.crypto.Error if the key can't be parsed.
        """
        parsed_pem_key = _parse_pem_key(key)
        if parsed_pem_key:
            pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)
        else:
            password = _to_bytes(password, encoding='utf-8')
            pkey = crypto.load_pkcs12(key, password).get_privatekey()
        return OpenSSLSigner(pkey) 
开发者ID:satwikkansal,项目名称:OneClickDTU,代码行数:22,代码来源:_openssl_crypt.py

示例7: from_string

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def from_string(key, password='notasecret'):
        """Construct a Signer instance from a string.

        Args:
            key: string, private key in PEM format.
            password: string, password for private key file. Unused for PEM
                      files.

        Returns:
            Signer instance.

        Raises:
            NotImplementedError if the key isn't in PEM format.
        """
        parsed_pem_key = _parse_pem_key(key)
        if parsed_pem_key:
            pkey = RSA.importKey(parsed_pem_key)
        else:
            raise NotImplementedError(
                'PKCS12 format is not supported by the PyCrypto library. '
                'Try converting to a "PEM" '
                '(openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > '
                'privatekey.pem) '
                'or using PyOpenSSL if native code is an option.')
        return PyCryptoSigner(pkey) 
开发者ID:satwikkansal,项目名称:OneClickDTU,代码行数:27,代码来源:_pycrypto_crypt.py

示例8: _succeeds_helper

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def _succeeds_helper(self, password=None):
        self.assertEqual(True, client.HAS_OPENSSL)

        credentials = self._make_svc_account_creds()
        if password is None:
            password = credentials._private_key_password
        pem_contents = crypt.pkcs12_key_as_pem(
            credentials._private_key_pkcs12, password)
        pkcs12_key_as_pem = datafile('pem_from_pkcs12.pem')
        pkcs12_key_as_pem = _helpers._parse_pem_key(pkcs12_key_as_pem)
        alternate_pem = datafile('pem_from_pkcs12_alternate.pem')
        self.assertTrue(pem_contents in [pkcs12_key_as_pem, alternate_pem]) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:14,代码来源:test_crypt.py

示例9: test_valid_input

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def test_valid_input(self):
        test_string = b'1234-----BEGIN FOO BAR BAZ'
        result = _helpers._parse_pem_key(test_string)
        self.assertEqual(result, test_string[4:]) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:6,代码来源:test__helpers.py

示例10: test_bad_input

# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import _parse_pem_key [as 别名]
def test_bad_input(self):
        test_string = b'DOES NOT HAVE DASHES'
        result = _helpers._parse_pem_key(test_string)
        self.assertEqual(result, None) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:6,代码来源:test__helpers.py


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