本文整理汇总了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),
)
# 验证证书链父子关系(自签根证书,父子均为自身)