python解析der格式的证书

复制代码
from pyasn1.codec.ber import decoder
from pyasn1.type import univ
 
# 打开文件并读取内容
with open('data.ber', 'rb') as f:
    encoded_data = f.read()
 
# 解析BER编码的数据
asn1_object, rest = decoder.decode(encoded_data, asn1Spec=univ.Any())
print(asn1_object.prettyPrint())
复制代码

 pyasn1在win10的wsl里安装会报错,大概是enviroment error,直接用apt install python3-pyasn1安装。

posted @   shanxin1954  阅读(8)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示