Exemple #1
0
        public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, string context,
                                         AlertDescription defaultAlert = AlertDescription.InternalError)
        {
            if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_SUCCESS)
            {
                return;
            }

            var message = string.Format("{0} - error code: {1}", context, errorState.code);

            throw new TlsException(defaultAlert, message);
        }
Exemple #2
0
        public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState,
                                         UnityTls.unitytls_x509verify_result verifyResult, string context,
                                         AlertDescription defaultAlert = AlertDescription.InternalError)
        {
            // Ignore verify result if verification is not the issue.
            if (verifyResult == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS)
            {
                CheckAndThrow(errorState, context, defaultAlert);
                return;
            }

            var alert   = UnityTlsConversions.VerifyResultToAlertDescription(verifyResult, defaultAlert);
            var message = string.Format("{0} - error code: {1}, verify result: {2}", context, errorState.code,
                                        verifyResult);

            throw new TlsException(alert, message);
        }