Beispiel #1
0
bool KSSLD::cacheSeenCN(QString cn)
{
    KSSLCNode *node;

    for(node = certList.first(); node; node = certList.next())
    {
        if(KSSLX509Map(node->cert->getSubject()).getValue("CN") == cn)
        {
            if(!node->permanent && node->expires < QDateTime::currentDateTime())
            {
                certList.remove(node);
                cfg->deleteGroup(node->cert->getMD5Digest());
                delete node;
                cacheSaveToDisk();
                continue;
            }

            certList.remove(node);
            certList.prepend(node);
            return true;
        }
    }

    return false;
}
Beispiel #2
0
KSSLCertificateCache::KSSLCertificatePolicy KSSLD::cacheGetPolicyByCN(QString cn)
{
    KSSLCNode *node;

    for(node = certList.first(); node; node = certList.next())
    {
        if(KSSLX509Map(node->cert->getSubject()).getValue("CN") == cn)
        {
            if(!node->permanent && node->expires < QDateTime::currentDateTime())
            {
                certList.remove(node);
                cfg->deleteGroup(node->cert->getMD5Digest());
                delete node;
                continue;
            }

            certList.remove(node);
            certList.prepend(node);
            cacheSaveToDisk();
            return node->policy;
        }
    }

    cacheSaveToDisk();

    return KSSLCertificateCache::Unknown;
}
void KSSLD::cacheAddCertificate(KSSLCertificate cert, 
         KSSLCertificateCache::KSSLCertificatePolicy policy, bool permanent) {
  KSSLCNode *node;

  for (node = certList.first(); node; node = certList.next()) {
    if (cert == *(node->cert)) {
      node->policy = policy;
      node->permanent = permanent;
      if (!permanent) {
        node->expires = QDateTime::currentDateTime();
// FIXME: make this configurable
        node->expires = node->expires.addSecs(3600);
      }
      cacheSaveToDisk();
      return;
    }
  }

  KSSLCNode *n = new KSSLCNode;
  n->cert = cert.replicate();
  n->policy = policy;
  n->permanent = permanent;
  cacheRemoveByCN(KSSLX509Map(n->cert->getSubject()).getValue("CN")); // remove the old one
  certList.prepend(n); 
  if (!permanent) {
    n->expires = QDateTime::currentDateTime();
    n->expires = n->expires.addSecs(3600);
  }
  cacheSaveToDisk();
}
bool KSSLD::cacheRemoveByCN(QString cn) {
  KSSLCNode *node;
  bool gotOne = false;

  for (node = certList.first(); node; node = certList.next()) {
    if (KSSLX509Map(node->cert->getSubject()).getValue("CN") == cn) {
      certList.remove(node);
      cfg->deleteGroup(node->cert->getSubject());
      delete node;
      gotOne = true;
    }
  }
  cacheSaveToDisk();
  return gotOne;
}
bool KSSLD::cacheModifyByCN(QString cn,
                            KSSLCertificateCache::KSSLCertificatePolicy policy,                             bool permanent,
                            QDateTime expires) {
  KSSLCNode *node;

  for (node = certList.first(); node; node = certList.next()) {
    if (KSSLX509Map(node->cert->getSubject()).getValue("CN") == cn) {
      node->permanent = permanent;
      node->expires = expires;
      node->policy = policy;
      certList.remove(node);
      certList.prepend(node);
      cacheSaveToDisk();
      return true;
    }
  }
  return false;
}