public RecordProtocol(Stream innerStream, Context context)
		{
			this.innerStream			= innerStream;
			this.context				= context;
			this.context.RecordProtocol = this;
		}
Пример #2
0
		public void SetContext (Context context)
		{
			CheckDisposed ();
			if (masterSecret != null)
				context.MasterSecret = (byte[]) masterSecret.Clone ();
		}
		public TlsClientCertificate(Context context) 
			: base(context, HandshakeType.Certificate)
		{
		}
Пример #4
0
		static public bool SetContextFromCache (Context context)
		{
			lock (locker) {
				ClientSessionInfo csi = FromContext (context, true);
				if (csi == null)
					return false;

				csi.SetContext (context);
				csi.KeepAlive ();
				return true;
			}
		}
Пример #5
0
		static public bool SetContextInCache (Context context)
		{
			lock (locker) {
				// Don't check the validity because the masterKey of the ClientSessionInfo
				// can still be null when this is called the first time
				ClientSessionInfo csi = FromContext (context, false);
				if (csi == null)
					return false;

				csi.GetContext (context);
				csi.KeepAlive ();
				return true;
			}
		}
Пример #6
0
		// only called inside the lock
		static private ClientSessionInfo FromContext (Context context, bool checkValidity)
		{
			if (context == null)
				return null;

			byte[] id = context.SessionId;
			if ((id == null) || (id.Length == 0))
				return null;

			// do we have a session cached for this host ?
			string uid = BitConverter.ToString (id);

			ClientSessionInfo si = (ClientSessionInfo) cache[uid];
			if (si == null)
				return null;

			// In the unlikely case of multiple hosts using the same 
			// session id, we just act like we do not know about it
			if (context.ClientSettings.TargetHost != si.HostName)
				return null;

			// yes, so what's its status ?
			if (checkValidity && !si.Valid) {
				si.Dispose ();
				cache.Remove (uid);
				return null;
			}

			// ok, it make sense
			return si;
		}
		// only called inside the lock
		static private ServerSessionInfo FromContext (Context context, bool checkValidity)
		{
			if (context == null)
				return null;

			byte[] id = context.SessionId;
			if ((id == null) || (id.Length == 0))
				return null;

			// do we have a session cached for this host ?
			string uid = BitConverter.ToString (id);

			ServerSessionInfo si = (ServerSessionInfo) cache[uid];
			if (si == null)
				return null;

			// yes, so what's its status ?
			if (checkValidity && !si.Valid) {
				si.Dispose ();
				cache.Remove (uid);
				return null;
			}

			// ok, it make sense
			return si;
		}
		public TlsClientCertificate(Context context, byte[] buffer)
			: base(context, HandshakeType.Certificate, buffer)
		{
		}