<tfoot id='8FNOs'></tfoot>
  • <i id='8FNOs'><tr id='8FNOs'><dt id='8FNOs'><q id='8FNOs'><span id='8FNOs'><b id='8FNOs'><form id='8FNOs'><ins id='8FNOs'></ins><ul id='8FNOs'></ul><sub id='8FNOs'></sub></form><legend id='8FNOs'></legend><bdo id='8FNOs'><pre id='8FNOs'><center id='8FNOs'></center></pre></bdo></b><th id='8FNOs'></th></span></q></dt></tr></i><div id='8FNOs'><tfoot id='8FNOs'></tfoot><dl id='8FNOs'><fieldset id='8FNOs'></fieldset></dl></div>

        • <bdo id='8FNOs'></bdo><ul id='8FNOs'></ul>

        <small id='8FNOs'></small><noframes id='8FNOs'>

        <legend id='8FNOs'><style id='8FNOs'><dir id='8FNOs'><q id='8FNOs'></q></dir></style></legend>

        python中的简单DER证书解析

        Simple DER Cert Parsing in python(python中的简单DER证书解析)

        • <legend id='JopqW'><style id='JopqW'><dir id='JopqW'><q id='JopqW'></q></dir></style></legend>
            <tbody id='JopqW'></tbody>

            • <bdo id='JopqW'></bdo><ul id='JopqW'></ul>
              <i id='JopqW'><tr id='JopqW'><dt id='JopqW'><q id='JopqW'><span id='JopqW'><b id='JopqW'><form id='JopqW'><ins id='JopqW'></ins><ul id='JopqW'></ul><sub id='JopqW'></sub></form><legend id='JopqW'></legend><bdo id='JopqW'><pre id='JopqW'><center id='JopqW'></center></pre></bdo></b><th id='JopqW'></th></span></q></dt></tr></i><div id='JopqW'><tfoot id='JopqW'></tfoot><dl id='JopqW'><fieldset id='JopqW'></fieldset></dl></div>

                1. <tfoot id='JopqW'></tfoot>

                  <small id='JopqW'></small><noframes id='JopqW'>

                  本文介绍了python中的简单DER证书解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 python 解析具有 DER 格式的 X509 证书的二进制文件以提取公钥的最佳方法是什么.

                  Which is the best way to parse with python a binary file with X509 Certificate in DER format to extract public key.

                  推荐答案

                  Python 内置的 SSL 模块和 PyOpenSSL 都没有 API 来提取私钥并访问其信息.M2Crypto 不再维护,并且不适用于 OpenSSL 1.0 及更高版本.

                  Neither the built-in SSL module of Python nor PyOpenSSL have an API to extract the private key and access its information. M2Crypto is no longer maintained and doesn't work with OpenSSL 1.0 and newer.

                  PyOpenSSL 有一个公钥类,但它的功能有限:

                  PyOpenSSL has a public key class but its features are limited:

                  >>> with open("cert.der", "rb") as f:
                  ...     der = f.read()
                  ... 
                  >>> import OpenSSL.crypto
                  >>> x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, der)
                  >>> pkey = x509.get_pubkey()
                  >>> dir(pkey)
                  ['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'bits', 'check', 'generate_key', 'type']
                  >>> pkey.bits()
                  4096L
                  >>> pkey.type() == OpenSSL.crypto.TYPE_RSA
                  True
                  

                  Python 3.4 可能会获得 X509 类型,该类型会公开更多信息,例如 SPKI.

                  Python 3.4 may get a X509 type that exposes more information like SPKI.

                  这篇关于python中的简单DER证书解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                  • <bdo id='fwhaq'></bdo><ul id='fwhaq'></ul>

                          <tbody id='fwhaq'></tbody>

                      1. <small id='fwhaq'></small><noframes id='fwhaq'>

                        <legend id='fwhaq'><style id='fwhaq'><dir id='fwhaq'><q id='fwhaq'></q></dir></style></legend>

                        • <i id='fwhaq'><tr id='fwhaq'><dt id='fwhaq'><q id='fwhaq'><span id='fwhaq'><b id='fwhaq'><form id='fwhaq'><ins id='fwhaq'></ins><ul id='fwhaq'></ul><sub id='fwhaq'></sub></form><legend id='fwhaq'></legend><bdo id='fwhaq'><pre id='fwhaq'><center id='fwhaq'></center></pre></bdo></b><th id='fwhaq'></th></span></q></dt></tr></i><div id='fwhaq'><tfoot id='fwhaq'></tfoot><dl id='fwhaq'><fieldset id='fwhaq'></fieldset></dl></div>
                          <tfoot id='fwhaq'></tfoot>