TSystems.RELOAD.Enroll.ReloadConfigResolve.EnrollmentProcedure C# (CSharp) Method

EnrollmentProcedure() public method

public EnrollmentProcedure ( ) : void
return void
    public void EnrollmentProcedure() {

      m_ReloadConfig.ReloadLocalNetCertStorage = new MemoryCertStorage();
      m_ReloadConfig.ReloadLocalNetCertStorage.Clear();

      if(ReloadGlobals.SelfSignPermitted)
      {
          String subjectName = "reload:" + ReloadGlobals.IPAddressFromHost(m_ReloadConfig, ReloadGlobals.HostName).ToString() + ":" + m_ReloadConfig.ListenPort;
          //string subjectName = TSystems.RELOAD.Enroll.EnrollmentSettings.Default.CN;
          X509Certificate2 cert = Utils.X509Utils.CreateSelfSignedCertificateCOM(subjectName);

          m_ReloadConfig.ReloadLocalNetCertStorage.Add(cert, true);
      }

      if (EnrollmentUrl != "" && !ReloadGlobals.SelfSignPermitted)
        if (CertificateSigningRequest(EnrollmentUrl) == false) {
          if (m_ReloadConfig.CertName.Length > 0) {
            FileStream fs = new FileStream(m_ReloadConfig.CertName, FileMode.Open, FileAccess.Read);
            try
            {
                m_ReloadConfig.ReloadLocalNetCertStorage.LoadFromStreamPFX(fs, m_ReloadConfig.CertPassword, (int)fs.Length);
            }
            catch (Exception ex)
            {
                m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, String.Format("Failed loading certificate: {0}", ex.Message));
            }

          }
        }

      try {

        m_ReloadConfig.MyCertificate = m_ReloadConfig.ReloadLocalNetCertStorage.get_Certificates(0);
      
        if(m_ReloadConfig.MyCertificate == null)
            throw new System.Exception("Got no certificate!");

        if(m_ReloadConfig.MyCertificate.Extensions[0] == null)
            throw new System.Exception("Got no certificate!");

        /* RELOAD BASE 07, pg. 112 */
        //try {
          //ReloadGlobals.SelfSignPermitted = m_ReloadConfig.Document.Overlay.configuration.selfsignedpermitted.Value; // set in Resolve.cs: ReadConfig()
        //}
        //catch { };

        if (m_ReloadConfig.MyCertificate.Issuer == m_ReloadConfig.MyCertificate.Subject)
        {
          if (!ReloadGlobals.SelfSignPermitted)
            throw new System.Exception("Found self signed certificate, but self signing is not allowed by config");
        }

        string rfc822Name = null;
        m_ReloadConfig.LocalNodeID = ReloadGlobals.retrieveNodeIDfromCertificate(m_ReloadConfig.MyCertificate, ref rfc822Name);

        if (rfc822Name != null) {
          if (m_ReloadConfig.IMSI != null && m_ReloadConfig.IMSI != "" && m_ReloadConfig.IMSI != "VNODE") {
            string[] rfc822NameSplit = rfc822Name.Split(':', ',', '/', '@');

            m_ReloadConfig.E64_Number = rfc822NameSplit[0];
            m_ReloadConfig.SipUri = "sip:" + rfc822Name;
            m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO,
              String.Format("Enrollment Server assigned: NodeId = '{0}' SipUri = '{1}' ", m_ReloadConfig.LocalNodeID, m_ReloadConfig.SipUri));
          }
          else
            m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO, String.Format("Enrollment Server assigned: NodeId = '{0}'", m_ReloadConfig.LocalNodeID));
        }
        System.Diagnostics.Debug.Assert(m_ReloadConfig.LocalNodeID != null && m_ReloadConfig.LocalNodeID != m_ReloadConfig.LocalNodeID.Max() && m_ReloadConfig.LocalNodeID != m_ReloadConfig.LocalNodeID.Min());
      }
      catch (Exception ex) {
        m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "EnrollmentProcedure: " + ex.Message);
      }
    }

Usage Example

Esempio n. 1
0
    public bool Init() {

      try {
        if (ReloadGlobals.IgnoreSSLErrors)
          IgnoreSSLErrors();

        m_transport = new MessageTransport();

        if (ReloadGlobals.TLS)
          m_interface_flm = new ReloadFLM(ReloadConfig);
        else
          m_interface_flm = new SimpleFLM(ReloadConfig);

        ReloadConfig.Statistics.SetParams(m_interface_flm);
        m_interface_flm.ReloadFLMEventHandler += 
          new ReloadFLMEvent(m_transport.rfm_ReloadFLMEventHandler);

        ReloadConfig.State = ReloadConfig.RELOAD_State.Init;
        stateUpdates(ReloadConfig.RELOAD_State.Init);

        ReloadConfigResolve resolve = new ReloadConfigResolve(ReloadConfig);

        resolve.ReadConfig();
        if (ReloadGlobals.TLS)
          resolve.EnrollmentProcedure();
        else
          resolve.SimpleNodeIdRequest();

        m_interface_flm.Init();
        m_ReloadConfig.AccessController = new AccessController(m_ReloadConfig);
        m_topology = new TopologyPlugin(this);
        if (!m_topology.Init(this))
          return false;

        m_forwarding = new ForwardingLayer(this);
        m_transport.Init(this);

        //ReloadConfig.State = ReloadConfig.RELOAD_State.Configured;
        //stateUpdates(ReloadConfig.RELOAD_State.Configured);
        BootStrapConfig();

        m_ReloadConfig.StartJoining = DateTime.Now;
        if (m_ReloadConfig.IamClient)
          m_ReloadConfig.StartJoinMobile = DateTime2.Now;
        if (!ReloadConfig.IsBootstrap)
          Arbiter.Activate(ReloadConfig.DispatcherQueue, 
            new IterativeTask<List<BootstrapServer>>(m_BootstrapServerList,
            m_transport.PreJoinProdecure));

//        m_worker_thread.ReportProgress(100); --joscha
        InitUsageManager();
        ReloadConfig.State = ReloadConfig.RELOAD_State.Configured;
        stateUpdates(ReloadConfig.RELOAD_State.Configured);

        /* reporting service */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(Reporting));
        /* chord-ping-interval */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(Maintenance));
        /* chord-update-interval */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(UpdateCycle));
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(CommandCheckTask));
      }
      catch (Exception ex) {
        ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "Init: " + ex.Message);
      }
      return true;
    }