Пример #1
0
            }             // proc ResetScript

            public void Run(bool throwExceptions)
            {
                lock (scriptLock)
                    using (var m = log.CreateScope(LogMsgType.Information, true, true))
                        try
                        {
                            if (GetScript(throwExceptions) == null)
                            {
                                m.SetType(LogMsgType.Warning)
                                .WriteLine("Script not found.");
                                return;
                            }

                            currentScript.Chunk.Run(table);
                            m.WriteLine("Executed.");

                            needToRun = false;
                            OnScriptCompiled();
                        }
                        catch (Exception e)
                        {
                            if (throwExceptions)
                            {
                                throw;
                            }

                            m.WriteException(e);
                        }
            }             // proc Run
Пример #2
0
        public static bool SslRemoteCertificateValidate(LoggerProxy log, bool skipInvalidCertificate, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
            {
                return(true);
            }

            using (var m = log.CreateScope(skipInvalidCertificate ? LogMsgType.Warning : LogMsgType.Error))
            {
                m.WriteLine("Remote certification validation failed ({0}).", sslPolicyErrors);
                m.WriteLine();
                m.WriteLine("Remote Certificate:");
                if (certificate != null)
                {
                    m.WriteLine("  Subject: {0}", certificate.Subject);
                    m.WriteLine("  CertHash: {0}", certificate.GetCertHashString());
                    m.WriteLine("  Expiration: {0}", certificate.GetExpirationDateString());
                    m.WriteLine("  Serial: {0}", certificate.GetSerialNumberString());
                    m.WriteLine("  Algorithm: {0}", certificate.GetKeyAlgorithmParametersString());
                }
                else
                {
                    m.WriteLine("  <null>");
                    // no chance to skip
                    return(skipInvalidCertificate);
                }

                m.WriteLine("Chain:");

                var i = 0;
                foreach (var c in chain.ChainElements)
                {
                    m.Write("  - {0}", c.Certificate?.Subject);
                    if (i < chain.ChainStatus.Length)
                    {
                        m.WriteLine(" --> {0}, {1}", chain.ChainStatus[i].Status, chain.ChainStatus[i].StatusInformation);
                    }
                    else
                    {
                        m.WriteLine();
                    }
                    i++;
                }
            }

            return(skipInvalidCertificate);
        } // func SslRemoteCertificateValidate
Пример #3
0
        public static bool SslRemoteCertificateValidate(LoggerProxy log, bool skipInvalidCertificate, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
                return true;

            using (var m = log.CreateScope(skipInvalidCertificate ? LogMsgType.Warning : LogMsgType.Error))
            {
                m.WriteLine("Remote certification validation failed ({0}).", sslPolicyErrors);
                m.WriteLine();
                m.WriteLine("Remote Certificate:");
                if (certificate != null)
                {
                    m.WriteLine("  Subject: {0}", certificate.Subject);
                    m.WriteLine("  CertHash: {0}", certificate.GetCertHashString());
                    m.WriteLine("  Expiration: {0}", certificate.GetExpirationDateString());
                    m.WriteLine("  Serial: {0}", certificate.GetSerialNumberString());
                    m.WriteLine("  Algorithm: {0}", certificate.GetKeyAlgorithmParametersString());
                }
                else
                {
                    m.WriteLine("  <null>");
                    // no chance to skip
                    return false;
                }

                m.WriteLine("Chain:");

                var i = 0;
                foreach (var c in chain.ChainElements)
                {
                    m.Write("  - {0}", c.Certificate?.Subject);
                    if (i < chain.ChainStatus.Length)
                        m.WriteLine(" --> {0}, {1}", chain.ChainStatus[i].Status, chain.ChainStatus[i].StatusInformation);
                    else
                        m.WriteLine();
                    i++;
                }
            }

            return skipInvalidCertificate;
        }