本文整理匯總了Python中asn1crypto.pem.armor方法的典型用法代碼示例。如果您正苦於以下問題:Python pem.armor方法的具體用法?Python pem.armor怎麽用?Python pem.armor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類asn1crypto.pem
的用法示例。
在下文中一共展示了pem.armor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: to_pem
# 需要導入模塊: from asn1crypto import pem [as 別名]
# 或者: from asn1crypto.pem import armor [as 別名]
def to_pem(self):
"""Get the PEM-encoding of the certificate."""
return pem.armor(self.PEM_MARKERS[0], self.to_der())
示例2: armor
# 需要導入模塊: from asn1crypto import pem [as 別名]
# 或者: from asn1crypto.pem import armor [as 別名]
def armor(self, expected_bytes_filename, relative_path, type_name, headers):
with open(os.path.join(fixtures_dir, relative_path), 'rb') as f:
byte_string = f.read()
encoded_bytes = pem.armor(type_name, byte_string, headers=headers)
with open(os.path.join(fixtures_dir, expected_bytes_filename), 'rb') as f:
expected_bytes = f.read()
# In case a user on Windows has CRLF translation on in Git.
# Ran into this with the GitHub Actions Windows environments.
expected_bytes = expected_bytes.replace(b'\r\n', b'\n')
self.assertEqual(expected_bytes, encoded_bytes)
示例3: test_armor_wrong_type
# 需要導入模塊: from asn1crypto import pem [as 別名]
# 或者: from asn1crypto.pem import armor [as 別名]
def test_armor_wrong_type(self):
with self.assertRaisesRegex(TypeError, 'type_name must be a unicode string'):
pem.armor(b'CERTIFICATE', b'')
示例4: test_armor_wrong_type2
# 需要導入模塊: from asn1crypto import pem [as 別名]
# 或者: from asn1crypto.pem import armor [as 別名]
def test_armor_wrong_type2(self):
with self.assertRaisesRegex(TypeError, 'der_bytes must be a byte string'):
pem.armor('CERTIFICATE', '')
示例5: dump
# 需要導入模塊: from asn1crypto import pem [as 別名]
# 或者: from asn1crypto.pem import armor [as 別名]
def dump(self):
return (
self.fgprint,
self.certobj.issuer.human_friendly,
self.certobj.subject.human_friendly,
pem.armor('CERTIFICATE', self.certder),
)
# 驗證證書鏈父子關係(自簽根證書,父子均為自身)