Ejemplo n.º 1
0
        /// <summary>
        /// Remove the certificate for the specified host.
        /// </summary>
        /// <param name="host">The host the certificate belongs to.</param>
        public static void RemoveCertificate(string host)
        {
            string uriHost = GetHostFromUri(host);

            log.Debug("removing for host : {0}", uriHost);
            CertPolicy.RemoveCertificate(uriHost);
            log.Debug("removed for host : {0}", uriHost);

            // also remove it from store , if any
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(store.LocalDomain);

            // Check for an existing cert in the store.
            Node    cn       = null;
            ICSList nodeList = domain.Search(hostProperty, uriHost, SearchOp.Equal);

            foreach (ShallowNode sn in nodeList)
            {
                cn = new Node(domain, sn);
                if (cn.IsType(CertType))
                {
                    Property myprop = cn.Properties.GetSingleProperty(certificateProperty);
                    if (myprop != null)
                    {
                        domain.Commit(domain.Delete(cn));
                        log.Debug("committed the deletion of certtype node for :{0} ", uriHost);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove the certificate for the specified host.
        /// </summary>
        /// /// <param name="domainID">the domainid for this host</param>
        /// <param name="host">The host the certificate belongs to.</param>
        public static void RemoveDomainCertificate(string domainID, string host)
        {
            // this API is yet to be tested , and has not been used.

            string uriHost = GetHostFromUri(host);

            log.Debug("removing for host : {0}", uriHost);
            CertPolicy.RemoveCertificate(uriHost);
            log.Debug("removed for host : {0}", uriHost);

            // also remove it from store , if any
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(domainID);

            // check for the cert
            Node    cn       = null;
            ICSList nodelist = domain.Search(hostProperty, "*", SearchOp.Equal);  //domain.GetNodesByType(CertType);

            if (nodelist == null)
            {
                log.Debug("returned null for hostproperty * ");
            }
            foreach (ShallowNode sn in nodelist)
            {
                cn = new Node(domain, sn);
                if (!cn.IsType(CertType))
                {
                    log.Debug("returned non null but this node is not of type CertType");
                    continue;
                }

                if (cn != null)
                {
                    // cert type is found
                    domain.Commit(domain.Delete(cn));
                    log.Debug("committed the deletion of certtype node for :{0} ", uriHost);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove the certificate for the specified host, only from CertTable
        /// </summary>
        /// <param name="host">The host the certificate belongs to.</param>
        public static void RemoveCertFromTable(string host)
        {
            string uriHost = GetHostFromUri(host);

            CertPolicy.RemoveCertificate(uriHost);
        }