示例#1
0
 public ServerAlertException(AlertDescription description) : base(description.ToString())
 {
     Description = description;
 }
示例#2
0
 public ClientAlertException(AlertDescription description, string message = null)
     : base(description.ToString() + (message != null ? ": " + message : ""))
 {
     Description = description;
     ExtraInfo   = message;
 }
示例#3
0
 public ClientAlertException(AlertDescription description, string message = null)
     : base(description.ToString() + (message != null ? ": " + message : ""))
 {
     Description = description;
     ExtraInfo = message;
 }
示例#4
0
 public ServerAlertException(AlertDescription description) : base(description.ToString())
 {
     Description = description;
 }
示例#5
0
        protected SslHandshakeStatus ProcessAlert(RecordMessage message)
        {
            if (message.length != 2 || message.fragment.Length != 2)
            {
                throw new SslException(AlertDescription.RecordOverflow, "The alert message is invalid.");
            }
            try {
                AlertLevel       level       = (AlertLevel)message.fragment[0];
                AlertDescription description = (AlertDescription)message.fragment[1];

                if (level == AlertLevel.Fatal && description == AlertDescription.NoApplicationProtocol)
                {
                    throw new ALPNCantSelectProtocolException();
                }

                if (level == AlertLevel.Fatal)
                {
                    throw new SslException(description, "The other side has sent a failure alert with code: " + description.ToString());
                }
                SslHandshakeStatus ret;
                if (description == AlertDescription.CloseNotify)
                {
                    if (m_State == HandshakeType.ShuttingDown)                       // true if we've already sent a shutdown notification
                    // close connection
                    {
                        ret = new SslHandshakeStatus(SslStatus.Close, null);
                    }
                    else
                    {
                        // send a shutdown notifications, and then close the connection
                        ret = new SslHandshakeStatus(SslStatus.Close, GetControlBytes(ControlType.Shutdown));
                    }
                }
                else
                {
                    ret = new SslHandshakeStatus(SslStatus.OK, null);
                }
                return(ret);
            } catch (SslException) {
                throw;
            } catch (Exception e) {
                throw new SslException(e, AlertDescription.InternalError, "There was an internal error.");
            }
        }