Export (0) Print
Expand All

SignedCms.Decode Method

The Decode method decodes an encoded SignedCms message. Upon successful decoding, the decoded information can be retrieved from the properties of the SignedCms object.

Namespace: System.Security.Cryptography.Pkcs
Assembly: System.Security (in system.security.dll)

public void Decode (
	byte[] encodedMessage
)
public void Decode (
	byte[] encodedMessage
)
public function Decode (
	encodedMessage : byte[]
)
Not applicable.

Parameters

encodedMessage

Array of byte values that represents the encoded CMS/PKCS #7 message to be decoded.

Exception typeCondition

ArgumentNullException

A null reference was passed to a method that does not accept it as a valid argument.

CryptographicException

A cryptographic operation could not be completed.

This method resets all member variables of the object by using the information obtained from successful decoding.

The following example shows the placement of the Decode method in the process of verifying the signatures on a SignedCms message. In this example, the message content is not detached, so the message content is included in the SignedCms message.

// Create a new, nondetached SignedCms message.
SignedCms signedCms = new SignedCms();

// encodedMessage is the encoded message received from 
// the sender.
signedCms.Decode(encodedMessage);

// Verify the signature without validating the 
// certificate.
signedCms.CheckSignature(true);

The following example shows the placement of the Decode method in the process of verifying the signatures on a SignedCms message. In this example, the message content is detached, so the message content must be verified independently of the SignedCms message.

// Create a ContentInfo object from the inner content obtained 
// independently from encodedMessage.
ContentInfo contentInfo = new ContentInfo(innerContent);

// Create a new, detached SignedCms message.
SignedCms signedCms = new SignedCms(contentInfo, true);

// encodedMessage is the encoded message received from 
// the sender.
signedCms.Decode(encodedMessage);

// Verify the signature without validating the 
// certificate.
signedCms.CheckSignature(true);

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft