/// <summary> /// Verify the signed-data and return the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </summary> /// <remarks> /// Verifies the signed-data and returns the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </remarks> /// <returns>The list of digital signatures.</returns> /// <param name="ctx">The S/MIME context to use for verifying the signature.</param> /// <param name="entity">The unencapsulated entity.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="ctx"/> is <c>null</c>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The "smime-type" parameter on the Content-Type header is not "signed-data". /// </exception> /// <exception cref="System.FormatException"> /// The extracted content could not be parsed as a MIME entity. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The operation was cancelled via the cancellation token. /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public DigitalSignatureCollection Verify(SecureMimeContext ctx, out MimeEntity entity, CancellationToken cancellationToken = default(CancellationToken)) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (SecureMimeType != SecureMimeType.SignedData && SecureMimeType != SecureMimeType.Unknown) { throw new InvalidOperationException(); } using (var memory = new MemoryBlockStream()) { Content.DecodeTo(memory); memory.Position = 0; return(ctx.Verify(memory, out entity, cancellationToken)); } }
/// <summary> /// Verifies the signed-data and returns the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </summary> /// <remarks> /// Verifies the signed-data and returns the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </remarks> /// <returns>The list of digital signatures.</returns> /// <param name="ctx">The S/MIME context to use for verifying the signature.</param> /// <param name="entity">The unencapsulated entity.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="ctx"/> is <c>null</c>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The "smime-type" parameter on the Content-Type header is not "signed-data". /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public DigitalSignatureCollection Verify(SecureMimeContext ctx, out MimeEntity entity) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (SecureMimeType != SecureMimeType.SignedData) { throw new InvalidOperationException(); } using (var memory = new MemoryBlockStream()) { ContentObject.DecodeTo(memory); memory.Position = 0; return(ctx.Verify(memory, out entity)); } }
/// <summary> /// Verifies the signed-data and returns the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </summary> /// <remarks> /// Verifies the signed-data and returns the unencapsulated <see cref="MimeKit.MimeEntity"/>. /// </remarks> /// <returns>The list of digital signatures.</returns> /// <param name="ctx">The S/MIME context to use for verifying the signature.</param> /// <param name="entity">The unencapsulated entity.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="ctx"/> is <c>null</c>. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The "smime-type" parameter on the Content-Type header is not "signed-data". /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public DigitalSignatureCollection Verify (SecureMimeContext ctx, out MimeEntity entity) { if (ctx == null) throw new ArgumentNullException ("ctx"); if (SecureMimeType != SecureMimeType.SignedData) throw new InvalidOperationException (); using (var memory = new MemoryBlockStream ()) { ContentObject.DecodeTo (memory); memory.Position = 0; return ctx.Verify (memory, out entity); } }