简体   繁体   English

使用c#.net使用证书签署电子邮件

[英]Sign Email with Certificate using c#.net

I am trying to send email with "From Certificate". 我正在尝试发送带有“发自证书”的电子邮件。 I am using Framework 4.0, and in C# X509Certificates class. 我正在使用Framework 4.0,并且在C#X509Certificates类中。

SmtpClient sc = new SmtpClient(mSMTPServer, mSMTPPort);
sc.EnableSsl = true;
sc.ClientCertificates.Add(new X509Certificate(certificatePath, certPassword)); 
sc.Send(mail);

Problem I am facing is certificate is not attached or signed with email "from" part. 我面临的问题是证书未附加或未通过电子邮件“来自”部分签名。 Can any one help me please, how I signed from part of email using C#.NET and Framework 4.0? 有人可以帮我吗,我如何使用C#.NET和Framework 4.0从部分电子邮件中签名?

UPDATED: Look at this link: 更新:查看此链接:

http://www.codeproject.com/Articles/41727/An-S-MIME-Library-for-sending-and-Signed-Encrypted http://www.codeproject.com/Articles/41727/An-S-MIME-Library-for-sending-and-Signed-Encrypted

For only sign, pass the parameter to encrypt as null. 对于唯一符号,请传递参数以将其加密为null。

I'd recommend taking a look at MimeKit which you can use to digitally sign your email messages. 我建议您看一下MimeKit ,您可以将其用于对电子邮件进行数字签名。

Then once you have a signed email, you can send it using MailKit 's SmtpClient class which is very similar to System.Net.Mail.SmtpClient. 然后,一旦收到签名的电子邮件,就可以使用MailKit的SmtpClient类发送电子邮件,该类与System.Net.Mail.SmtpClient非常相似。

System.Net.Mail.SmtpClient.ClientCertificates are not used for signing the message, they are ONLY used for authenticating with the server via SSL. System.Net.Mail.SmtpClient.ClientCertificates不用于对消息签名,它们仅用于通过SSL与服务器进行身份验证。

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

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