當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。