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

      <tfoot id='w6RQr'></tfoot>
    1. <small id='w6RQr'></small><noframes id='w6RQr'>

    2. <legend id='w6RQr'><style id='w6RQr'><dir id='w6RQr'><q id='w6RQr'></q></dir></style></legend>
        <bdo id='w6RQr'></bdo><ul id='w6RQr'></ul>
    3. 从证书中提取公钥并加密数据

      extracting public key from certificate and encrypting data(从证书中提取公钥并加密数据)

        <bdo id='uVH4W'></bdo><ul id='uVH4W'></ul>
        <tfoot id='uVH4W'></tfoot>
          <legend id='uVH4W'><style id='uVH4W'><dir id='uVH4W'><q id='uVH4W'></q></dir></style></legend>
        1. <small id='uVH4W'></small><noframes id='uVH4W'>

              <tbody id='uVH4W'></tbody>

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

                本文介绍了从证书中提取公钥并加密数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是家庭作业!我使用 get_peer_certificate() 获得服务器的证书并调用 dump_certificate 将证书转储到变量中.格式是 PEM,我觉得很合适.

                This is for a homework assignment! I get the server's certificate using get_peer_certificate() and the calling dump_certificate to dump the certificate in a variable. The format is PEM and looks right to me.

                -----BEGIN CERTIFICATE-----
                GIBBERISH................
                ......................
                ........................
                
                -----END CERTIFICATE-----
                

                如何从这个文件 ('server.pubkey') 中提取服务器的公钥并使用 RSA 算法和任何 python 库加密 plaintext.在撰写本文时,我正在使用 pyOpenSSL

                How do I extract the server's public key from this file ('server.pubkey') and encrypt plaintext using RSA algorithm and any python library. At the time of writing this, I am using pyOpenSSL

                推荐答案

                我建议使用更广泛的 加密库如 M2Crypto 具有 X509 证书功能以及 RSA 加密:

                I'd recommend using a more broad crypto library such as M2Crypto which has the X509 certificate functions as well as RSA encryption:

                from M2Crypto import RSA, X509
                data = ssl_sock.getpeercert(1)
                # load the certificate into M2Crypto to manipulate it
                cert = X509.load_cert_string(data, X509.FORMAT_DER)
                pub_key = cert.get_pubkey()
                rsa_key = pub_key.get_rsa()
                cipher = rsa_key.public_encrypt('plaintext', RSA.pkcs1_padding)
                

                这篇关于从证书中提取公钥并加密数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                How to extend Python class init(如何扩展 Python 类初始化)
                What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                Initialize list with same bool value(使用相同的布尔值初始化列表)
                setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)

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

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