Example #1
0
        private X509Certificate2 GetCertificate(IConfigurationRoot configuration)
        {
            if (IsLocalConnection(configuration))
            {
                return(null); // localhost, no TLS
            }

            X509Certificate2 certificate = null;
            var certName = _securityOptions.X509CertificateName ?? Invariant($"CN={Environment.MachineName}");

            certificate = Certificates.GetCertificateForEncryption(certName);
            if (certificate == null)
            {
#if DEBUG
                return(null);
#else
                CommonStartup.Exit((int)BrokerExitCodes.NoCertificate, Resources.Critical_NoTlsCertificate, certName);
#endif
            }

            _logger.LogInformation(Resources.Trace_CertificateIssuer, certificate.Issuer);
            _logger.LogInformation(Resources.Trace_CertificateSubject, certificate.Subject);

            return(certificate);
        }
Example #2
0
        private void PingTimeout(object state)
        {
            var cts = (CancellationTokenSource)state;

            if (_cts == cts)
            {
                _logger.LogCritical(Resources.Critical_PingTimeOut);
                CommonStartup.Exit();
            }
        }
Example #3
0
        public void Initialize()
        {
            if (_options.ParentProcessID != null)
            {
                int     pid = _options.ParentProcessID.Value;
                Process process;
                try {
                    process = Process.GetProcessById(pid);
                    process.EnableRaisingEvents = true;
                } catch (ArgumentException) {
                    _logger.LogCritical(Resources.Critical_ParentProcessNotFound, pid);
                    CommonStartup.Exit();
                    return;
                }

                _logger.LogInformation(Resources.Info_MonitoringParentProcess, pid);
                process.Exited += delegate {
                    _logger.LogInformation(Resources.Info_ParentProcessExited, pid);
                    CommonStartup.Exit();
                };
            }

            Ping();
        }
Example #4
0
 protected override void OnStop()
 {
     CommonStartup.Exit();
 }