/** * Terminate this connection with an alert. * <p/> * Can be used for normal closure too. * * @param alertLevel The level of the alert, an be AlertLevel.fatal or AL_warning. * @param alertDescription The exact alert message. * @throws IOException If alert was fatal. */ private void FailWithError(AlertLevel alertLevel, AlertDescription alertDescription) { /* * Check if the connection is still open. */ if (!closed) { /* * Prepare the message */ this.closed = true; if (alertLevel == AlertLevel.fatal) { /* * This is a fatal message. */ this.failedWithError = true; } SendAlert(alertLevel, alertDescription); rs.Close(); if (alertLevel == AlertLevel.fatal) { throw new IOException(TLS_ERROR_MESSAGE); } } else { throw new IOException(TLS_ERROR_MESSAGE); } }
internal void SendAlert(AlertLevel alertLevel, AlertDescription alertDescription) { byte[] error = new byte[2]; error[0] = (byte)alertLevel; error[1] = (byte)alertDescription; rs.WriteMessage(ContentType.alert, error, 0, 2); }
public static string GetText(byte alertDescription) { return(string.Concat(new object[] { AlertDescription.GetName(alertDescription), "(", alertDescription, ")" })); }
public TlsFatalAlert(AlertDescription alertDescription) { this.alertDescription = alertDescription; }
private void FailWithError(AlertDescription alertDescription, Exception ex) { this.FailWithError(AlertLevel.fatal, alertDescription, ex); }
/** * Terminate this connection with an alert. * <p/> * Can be used for normal closure too. * * @param alertLevel The level of the alert, an be AlertLevel.fatal or AL_warning. * @param alertDescription The exact alert message. * @throws IOException If alert was fatal. */ private void FailWithError(AlertLevel alertLevel, AlertDescription alertDescription) { this.FailWithError(alertLevel, alertDescription, null); }