简体   繁体   English

如何使用X509证书和C#进行非对称加密?

[英]How to do asymmetric encryption with X509 certificates and C#?

I am looking to encrypt files with X509 certificates using public and private keys and send them to a remote server. 我正在寻找使用公钥和私钥用X509证书加密文件并将它们发送到远程服务器。 How would I do this? 我该怎么做? Is this even possible? 这有可能吗? How do I generate the certificate and then the public and private key pairs? 如何生成证书,然后生成公钥和私钥对?

See this SO question how to create a RSACryptoServiceProvider from a X509Certificate2 that can be used to encrypt and decrypt files. 看到这个SO问题,如何从X509Certificate2创建RSACryptoServiceProvider ,可用于加密和解密文件。

The .NET framework does not contain classes to generate X.509 certificates. .NET框架不包含用于生成X.509证书的类。 Mono's security classes ( Mono.Security.X509 ) and BouncyCastle support the creation of X.509 certificates from C#. Mono的安全类Mono.Security.X509 )和BouncyCastle支持从C#创建X.509证书。 Alternatively, you can use tools like OpenSSL or makecert.exe to generate certificates. 或者,您可以使用OpenSSL或makecert.exe类的工具来生成证书。

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

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