简体   繁体   English

使用公钥进行Openssl解密

[英]Openssl decryption using a public key

I need to decrypt a file which is encrypted using a private key. 我需要解密使用私钥加密的文件。 I have a public key which I can use to decrypt this file. 我有一个公钥,我可以用来解密这个文件。 How can I do this. 我怎样才能做到这一点。 I did: 我做了:

openssl rsautl -in file -inkey key.pem

But this is not working. 但这不起作用。 This shows the error as: 这显示错误为:

unable to load Private Key
3074128072:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: ANY PRIVATE KEY

公钥不能用于解密,它们只能用于加密和验证加密签名。

Contrary to everyone, you can in fact decrypt using a Public Key, only however , if your data was encrypted with the appropriate Private Key. 与每个人相反,您实际上可以使用公钥解密, 但是 ,如果您的数据是使用适当的私钥加密的。

As to how you go about decrypting it, from what I can see the openssl utility doesn't ship with this functionality. 至于你如何解密它,从我所看到的openssl实用程序没有附带此功能。 It seems you would have to use something that utilises the OpenSSL C API ( https://www.openssl.org/docs/man1.0.2/crypto/RSA_public_decrypt.html ). 看来你必须使用一些利用OpenSSL C API的东西( https://www.openssl.org/docs/man1.0.2/crypto/RSA_public_decrypt.html )。

Either use the C API directly or something like PHP's bindings to OpenSSL. 可以直接使用C API,也可以使用PHP绑定到OpenSSL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM