示例#1
0
文件: Nginx.cs 项目: liuqun/wnmp
 public void GenerateSSLKeyPair(string keyfile, string certfile)
 {
     try
     {
         CertGen certgen = new CertGen();
         certgen.GenerateSelfSignedCertificate("Wnmp", 2048, keyfile, certfile);
         Log.Notice("Generated SSL Keypair", ProgLogSection);
     }
     catch (Exception ex)
     {
         Log.Error("Failed to generate SSL Keypair: " + ex.Message, ProgLogSection);
     }
 }
示例#2
0
        private void CreateWnmpCertificate()
        {
            string ConfDir = Program.StartupPath + "\\conf";

            if (!Directory.Exists(ConfDir))
            {
                Directory.CreateDirectory(ConfDir);
            }

            string keyFile  = ConfDir + "\\key.pem";
            string certFile = ConfDir + "\\cert.pem";

            CertGen certgen = new CertGen();

            certgen.GenerateSelfSignedCertificate("Wnmp", 2048, keyFile, certFile);
        }
示例#3
0
文件: PoroServer.cs 项目: Kaotic/Poro
        public PoroServer(PoroServerSettings settings)
        {
            _settings = settings;

            //Create the Authentication Server to handle login requests and client page
            _auth = new AuthServer(HandleWebServ, _settings.AuthLocations);

            //Load the certificate store for the RTMPS server
            var certificateStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);

            certificateStore.Open(OpenFlags.MaxAllowed);

            //Remove last certificate in case it wasn't deleted on close
            foreach (var cert in certificateStore.Certificates)
            {
                if (cert.IssuerName.Name == string.Format("CN={0}", _settings.RTMPSHost))
                {
                    certificateStore.Remove(cert);
                }
            }

            //Generate new certificate for this run and add it to the store.
            var _rtmpsCert = CertGen.CreateSelfSignedCertificate(_settings.RTMPSHost);

            certificateStore.Add(_rtmpsCert);
            certificateStore.Close();

            //Generate the SerializationContext
            _context = new SerializationContext();
            var structures = Assembly.GetExecutingAssembly().GetTypes().Where(x => String.Equals(x.Namespace, "PoroLib.Structures", StringComparison.Ordinal));

            foreach (Type ObjectType in structures)
            {
                _context.Register(ObjectType);
            }

            //Create the RTMPS server with the context and certificate
            _server = new RtmpServer(new IPEndPoint(IPAddress.Parse(_settings.RTMPSHost), _settings.RTMPSPort), _context, _rtmpsCert);
            _server.ClientCommandReceieved += ClientCommandReceieved;
            _server.ClientMessageReceived  += ClientMessageReceived;

            //Set up the handler
            _handler = new MessageHandler();
            _handler.Register("LoginService");
            _handler.Register("MatchmakerService");
            _handler.Register("ClientFacadeService");
            _handler.Register("InventoryService");
            _handler.Register("MasteryBookService");
            _handler.Register("SummonerRuneService");
            _handler.Register("PlayerPreferencesService");
            _handler.Register("LcdsGameInvitationService");
            _handler.Register("SummonerTeamService");

            //Set up the forwarder
            _forwarder = new MessageForwarder(_context);

            //Set up the property redirector
            _redirector = new PropertyRedirector(_settings);

            //Set up the data loader
            _data = new DataLoader();
            _redirector.PatcherFound += new PropertyRedirector.PatcherFoundHandler(_data.LoadData);

            //Set up the user server
            _users = new UserHandler();
        }