MimeKit.Cryptography.X509CertificateStore.Import C# (CSharp) Method

Import() public method

Imports the certificate(s) from the specified stream.
Imports the certificate(s) from the specified stream.
/// is null. /// /// An error occurred reading the stream. ///
public Import ( Stream stream ) : void
stream Stream The stream to import.
return void
		public void Import (Stream stream)
		{
			if (stream == null)
				throw new ArgumentNullException ("stream");

			var parser = new X509CertificateParser ();

			foreach (X509Certificate certificate in parser.ReadCertificates (stream)) {
				if (unique.Add (certificate))
					certs.Add (certificate);
			}
		}

Same methods

X509CertificateStore::Import ( Stream stream, string password ) : void
X509CertificateStore::Import ( byte rawData ) : void
X509CertificateStore::Import ( byte rawData, string password ) : void
X509CertificateStore::Import ( string fileName ) : void
X509CertificateStore::Import ( string fileName, string password ) : void

Usage Example

コード例 #1
0
		public void TestArgumentExceptions ()
		{
			var store = new X509CertificateStore ();

			Assert.Throws<ArgumentNullException> (() => store.Add (null));
			Assert.Throws<ArgumentNullException> (() => store.AddRange (null));
			Assert.Throws<ArgumentNullException> (() => store.Export ((Stream) null, "password"));
			Assert.Throws<ArgumentNullException> (() => store.Export ((string) null, "password"));
			Assert.Throws<ArgumentNullException> (() => store.Export (Stream.Null, null));
			Assert.Throws<ArgumentNullException> (() => store.Export ("fileName", null));
			Assert.Throws<ArgumentNullException> (() => store.Export ((Stream) null));
			Assert.Throws<ArgumentNullException> (() => store.Export ((string) null));
			Assert.Throws<ArgumentNullException> (() => store.GetPrivateKey (null));
			Assert.Throws<ArgumentNullException> (() => store.Import ((Stream) null, "password"));
			Assert.Throws<ArgumentNullException> (() => store.Import ((string) null, "password"));
			Assert.Throws<ArgumentNullException> (() => store.Import ((byte[]) null, "password"));
			Assert.Throws<ArgumentNullException> (() => store.Import (Stream.Null, null));
			Assert.Throws<ArgumentNullException> (() => store.Import (GetTestDataPath ("smime.p12"), null));
			Assert.Throws<ArgumentNullException> (() => store.Import (new byte[0], null));
			Assert.Throws<ArgumentNullException> (() => store.Import ((Stream) null));
			Assert.Throws<ArgumentNullException> (() => store.Import ((string) null));
			Assert.Throws<ArgumentNullException> (() => store.Import ((byte[]) null));
			Assert.Throws<ArgumentNullException> (() => store.Remove (null));
			Assert.Throws<ArgumentNullException> (() => store.RemoveRange (null));
		}
All Usage Examples Of MimeKit.Cryptography.X509CertificateStore::Import