示例#1
0
        internal static void AddCertificateSelector(MSI.MonoTlsSettings settings, ICertificateSelector selector)
        {
            if (selector == null)
            {
                return;
            }

            settings.ClientCertificateSelectionCallback = (t, lc, rc, ai) => {
                return(((CertificateSelector)selector).SelectionCallback(null, t, lc, rc, ai));
            };
        }
示例#2
0
        public WebServer(int port, int httpsPort, ICertificateSelector certificateSelector, IPAddress bindAddr) : base(port, httpsPort, certificateSelector, bindAddr)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                webpackProxy = new WebpackProxy(9000, Globals.ApplicationDirectoryBase + "../../");
            }
#endif

            this.XForwardedForHeader = Settings.data.useXForwardedFor;
            this.XRealIPHeader       = Settings.data.useXRealIP;

            MvcJson.SerializeObject   = JsonConvert.SerializeObject;
            MvcJson.DeserializeObject = JsonConvert.DeserializeObject;
            mvcMain = new MVCMain(Assembly.GetExecutingAssembly(), typeof(Controllers.Auth).Namespace, MvcErrorHandler);
        }
示例#3
0
        public ErrorTrackerSvc()
        {
            Settings.data.Load();

            Logger.CatchAll((sender, e) =>
            {
                Emailer.SendError(null, sender, e);
            });

            Settings.data.SaveIfNoExist();

            if (Settings.data.CountUsers() == 0)
            {
                User defaultAdmin = new User("admin", "admin", null, true)
                {
                    Permanent = true
                };
                Settings.data.TryAddUser(defaultAdmin);
                defaultAdmin.InitializeUserId();
                Settings.data.Save();
            }
            if (string.IsNullOrWhiteSpace(Settings.data.systemName))
            {
                Settings.data.systemName = "Error Tracker";
                Settings.data.Save();
            }
            if (string.IsNullOrWhiteSpace(Settings.data.privateSigningKey))
            {
                Settings.data.privateSigningKey = new SignatureFactory().ExportPrivateKey();
                Settings.data.Save();
            }
            if (string.IsNullOrWhiteSpace(Settings.data.vapidPrivateKey) ||
                string.IsNullOrWhiteSpace(Settings.data.vapidPublicKey))
            {
                WebPush.VapidDetails vapidKeys = WebPush.VapidHelper.GenerateVapidKeys();
                Settings.data.vapidPrivateKey = vapidKeys.PrivateKey;
                Settings.data.vapidPublicKey  = vapidKeys.PublicKey;
                foreach (User u in Settings.data.GetAllUsers())
                {
                    u.ClearAllPushNotificationSubscriptions();
                }
                Settings.data.Save();
            }
            BPUtil.PasswordReset.StatelessPasswordResetBase.Initialize(Settings.data.privateSigningKey);

            // Initialize User IDs.
            bool setAny = false;

            foreach (User user in Settings.data.GetAllUsers())
            {
                if (user.InitializeUserId())
                {
                    setAny = true;
                }
            }
            if (setAny)
            {
                Settings.data.Save();
            }

            InitializeComponent();

            SvcName = this.ServiceName;

            ICertificateSelector certSelector = null;

            if (!string.IsNullOrWhiteSpace(Settings.data.certificatePath) && File.Exists(Settings.data.certificatePath))
            {
                X509Certificate2 cert;
                if (!string.IsNullOrWhiteSpace(Settings.data.certificatePassword))
                {
                    cert = new X509Certificate2(Settings.data.certificatePath, Settings.data.certificatePassword);
                }
                else
                {
                    cert = new X509Certificate2(Settings.data.certificatePath);
                }
                certSelector = SimpleCertificateSelector.FromCertificate(cert);
            }
            SimpleHttpLogger.RegisterLogger(Logger.httpLogger);
            srv = new WebServer(Settings.data.port_http, Settings.data.port_https, certSelector, IPAddress.Any);

            thrMaintainProjects              = new Thread(maintainProjects);
            thrMaintainProjects.Name         = "Maintain Projects";
            thrMaintainProjects.IsBackground = false;
        }
示例#4
0
		internal static void AddCertificateSelector (MSI.MonoTlsSettings settings, ICertificateSelector selector)
		{
			if (selector == null)
				return;

			settings.ClientCertificateSelectionCallback = (t, lc, rc, ai) => {
				return ((CertificateSelector)selector).SelectionCallback (null, t, lc, rc, ai);
			};
		}