/// <summary> /// Imports the certificates contained in the content. /// </summary> /// <remarks> /// Imports the certificates contained in the content. /// </remarks> /// <param name="ctx">The S/MIME context to import certificates into.</param> /// <exception cref="System.InvalidOperationException"> /// The "smime-type" parameter on the Content-Type header is not "certs-only". /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public void Import(SecureMimeContext ctx) { if (SecureMimeType != SecureMimeType.CertsOnly) { throw new InvalidOperationException(); } using (var memory = new MemoryBlockStream()) { ContentObject.DecodeTo(memory); memory.Position = 0; ctx.Import(memory); } }
/// <summary> /// Import the certificates contained in the content. /// </summary> /// <param name="ctx">The S/MIME context to import certificates into.</param> /// <exception cref="System.InvalidOperationException"> /// The "smime-type" parameter on the Content-Type header does not support decryption. /// </exception> public void Import(SecureMimeContext ctx) { // FIXME: find out what exceptions BouncyCastle can throw... if (SecureMimeType != SecureMimeType.CertsOnly) { throw new InvalidOperationException(); } using (var memory = new MemoryStream()) { ContentObject.WriteTo(memory); memory.Position = 0; ctx.Import(memory); } }
/// <summary> /// Import the certificates contained in the application/pkcs7-mime content. /// </summary> /// <remarks> /// Imports the certificates contained in the application/pkcs7-mime content. /// </remarks> /// <param name="ctx">The S/MIME context to import certificates into.</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 "certs-only". /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public void Import(SecureMimeContext ctx) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (SecureMimeType != SecureMimeType.CertsOnly && SecureMimeType != SecureMimeType.Unknown) { throw new InvalidOperationException(); } using (var memory = new MemoryBlockStream()) { Content.DecodeTo(memory); memory.Position = 0; ctx.Import(memory); } }
/// <summary> /// Imports the certificates contained in the content. /// </summary> /// <remarks> /// Imports the certificates contained in the content. /// </remarks> /// <param name="ctx">The S/MIME context to import certificates into.</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 "certs-only". /// </exception> /// <exception cref="Org.BouncyCastle.Cms.CmsException"> /// An error occurred in the cryptographic message syntax subsystem. /// </exception> public void Import (SecureMimeContext ctx) { if (ctx == null) throw new ArgumentNullException ("ctx"); if (SecureMimeType != SecureMimeType.CertsOnly) throw new InvalidOperationException (); using (var memory = new MemoryBlockStream ()) { ContentObject.DecodeTo (memory); memory.Position = 0; ctx.Import (memory); } }