コード例 #1
0
ファイル: SslClientStream.cs プロジェクト: Hengle/JellyTerain
 public SslClientStream(Stream stream, string targetHost, bool ownsStream, SecurityProtocolType securityProtocolType, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates)
     : base(stream, ownsStream)
 {
     if (targetHost == null || targetHost.Length == 0)
     {
         throw new ArgumentNullException("targetHost is null or an empty string.");
     }
     context  = new ClientContext(this, securityProtocolType, targetHost, clientCertificates);
     protocol = new ClientRecordProtocol(innerStream, (ClientContext)context);
 }
コード例 #2
0
		public SslClientStream(
			Stream						stream,
			string						targetHost,
			bool						ownsStream,
			SecurityProtocolType		securityProtocolType,
			X509CertificateCollection	clientCertificates)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream is null.");
			}
			if (!stream.CanRead || !stream.CanWrite)
			{
				throw new ArgumentNullException("stream is not both readable and writable.");
			}
			if (targetHost == null || targetHost.Length == 0)
			{
				throw new ArgumentNullException("targetHost is null or an empty string.");
			}

			this.context = new ClientContext(
				this,
				securityProtocolType, 
				targetHost, 
				clientCertificates);

			this.inputBuffer	= new MemoryStream();
			this.innerStream	= stream;
			this.ownsStream		= ownsStream;
			this.negotiate			= new object ();
			this.read			= new object ();
			this.write			= new object ();
			this.protocol		= new ClientRecordProtocol(innerStream, context);
		}