SignedCms.Decode Method

Definition

Overloads

Decode(Byte[])

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs

Decodes an encoded SignedCms message.

C#
public void Decode(byte[] encodedMessage);

Parameters

encodedMessage
Byte[]

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

Exceptions

encodedMessage is null.

encodedMessage could not be decoded successfully.

Examples

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.

C#
// 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.

C#
// 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);

Remarks

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

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Decode(ReadOnlySpan<Byte>)

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs
C#
public void Decode(ReadOnlySpan<byte> encodedMessage);

Parameters

encodedMessage
ReadOnlySpan<Byte>

A read-only span of byte values that represents the encoded CMS/PKCS#7 message to be decoded.

Exceptions

encodedMessage could not be decoded successfully.

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)
Windows Desktop 5, 6, 7, 8, 9