0 votes
by (170 points)
edited

Hi, I´m trying to create and verify an e-mail using VB.NET 2010. I have a problem, I do not know what part of my e-mail is "ContentInfo". I have a smime.p7s file, but looking your C# code on this old post: http://forum.rebex.net/questions/36/is-possible-use-rebex-security-cryptography-pkcs-namespace-for-external-detached, I can´t apply to my project in VB.NET 2010.

Could you say me what part of e-mail is "ContentInfo" and if you can, show me the VB.NET code.

Grettings

Applies to: Rebex Secure Mail

3 Answers

+1 vote
by (147k points)
edited

The C# code from that link is only intended for rare occurrences where you don't have any e-mail but have a stand-alone file and its signature (a .p7s file) instead and need to validate that.

Normally, you only need to validate a signed e-mail. In that case, all you need is the code from this tutorial:

C#

// create an instance of MailMessage 
MailMessage message = new MailMessage();

// load the message from a local disk file 
message.Load("c:\\message.eml");

// validate the signature if the message is signed 
if (message.IsSigned)
{
    MailSignatureValidity result = message.ValidateSignature();
    if (result.Valid)
        Console.WriteLine("The signature is valid.");
    else 
        Console.WriteLine("The signature is not valid.");
}
else 
{
    Console.WriteLine("The message is not signed.");
}

VB.NET

'create an instance of MailMessage 
Dim message As New MailMessage

'load the message from a local disk file 
message.Load("c:\message.eml")

'validate the signature if the message is signed 
If message.IsSigned Then 
    Dim result As MailSignatureValidity = message.ValidateSignature()
    If result.Valid Then 
        Console.WriteLine("The signature is valid.")
    Else 
        Console.WriteLine("The signature is not valid.")
    End If 
Else 
    Console.WriteLine("The message is not signed.")
End If 
0 votes
by (170 points)
edited

Ok, thanks Lukas, but I have my own library...then this code I can´t use.

However, I appreciate your help.

Best regards.

by (147k points)
In that case, check out sections 3.4.2 and 3.4.3 of RFC 3851 (http://www.ietf.org/rfc/rfc3851.txt) for more information about this - it describes which part of an e-mail is ContentInfo for two different signed message variants. ContentInfo is the content of the e-mail's multipart/signed
–2 votes
by
edited

I found this library for verifying email addresses in .net: http://www.kellermansoftware.com/p-37-net-email-validation.aspx

by (13.3k points)
edited

It seems like the product mentioned by you is for completly different kind of validation. Your link is for validation whether email address is valid. The original poster asked for crypto signature validation of email message content.

...