bool KSSLD::cacheAddHost(KSSLCertificate cert, TQString host) { KSSLCNode *node; if (host.isEmpty()) return true; for (node = certList.first(); node; node = certList.next()) { if (cert == *(node->cert)) { if (!node->permanent && node->expires < TQDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); searchRemoveCert(node->cert); delete node; cacheSaveToDisk(); return false; } if (!node->hosts.contains(host)) { node->hosts << host; } certList.remove(node); certList.prepend(node); cacheSaveToDisk(); return true; } } return false; }
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(); }
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; }
QStringList KSSLD::cacheGetHostList(KSSLCertificate cert) { KSSLCNode *node; for(node = certList.first(); node; node = certList.next()) { if(cert == *(node->cert)) { if(!node->permanent && node->expires < QDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); searchRemoveCert(node->cert); delete node; cacheSaveToDisk(); return QStringList(); } certList.remove(node); certList.prepend(node); return node->hosts; } } return QStringList(); }
bool KSSLD::cacheIsPermanent(KSSLCertificate cert) { KSSLCNode *node; for(node = certList.first(); node; node = certList.next()) { if(cert == *(node->cert)) { if(!node->permanent && node->expires < QDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); delete node; cacheSaveToDisk(); return false; } certList.remove(node); certList.prepend(node); return node->permanent; } } return false; }
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; }
KSSLCertificateCache::KSSLCertificatePolicy KSSLD::cacheGetPolicyByCertificate(KSSLCertificate cert) { KSSLCNode *node; for(node = certList.first(); node; node = certList.next()) { if(cert == *(node->cert)) { if(!node->permanent && node->expires < QDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); delete node; cacheSaveToDisk(); return KSSLCertificateCache::Unknown; } certList.remove(node); certList.prepend(node); return node->policy; } } return KSSLCertificateCache::Unknown; }
bool KSSLD::cacheRemoveHost(KSSLCertificate cert, QString host) { KSSLCNode *node; for (node = certList.first(); node; node = certList.next()) { if (cert == *(node->cert)) { if (!node->permanent && node->expires < QDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getSubject()); delete node; cacheSaveToDisk(); return false; } node->hosts.remove(host); certList.remove(node); certList.prepend(node); cacheSaveToDisk(); return true; } } return false; }
bool KSSLD::cacheRemoveByCertificate(KSSLCertificate cert) { KSSLCNode *node; for (node = certList.first(); node; node = certList.next()) { if (cert == *(node->cert)) { certList.remove(node); cfg->deleteGroup(node->cert->getSubject()); delete node; cacheSaveToDisk(); return true; } } return false; }
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 = TQDateTime::currentDateTime(); // FIXME: make this configurable node->expires = TQT_TQDATETIME_OBJECT(node->expires.addSecs(3600)); } cacheSaveToDisk(); return; } } KSSLCNode *n = new KSSLCNode; n->cert = cert.replicate(); n->policy = policy; n->permanent = permanent; // remove the old one cacheRemoveByCertificate(*(n->cert)); certList.prepend(n); if (!permanent) { n->expires = TQDateTime::currentDateTime(); n->expires = TQT_TQDATETIME_OBJECT(n->expires.addSecs(3600)); } searchAddCert(n->cert); 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::cacheRemoveBySubject(TQString subject) { KSSLCNode *node; bool gotOne = false; for (node = certList.first(); node; node = certList.next()) { if (node->cert->getSubject() == subject) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); searchRemoveCert(node->cert); delete node; gotOne = true; } } cacheSaveToDisk(); return gotOne; }
bool KSSLD::cacheModifyByCertificate(KSSLCertificate cert, KSSLCertificateCache::KSSLCertificatePolicy policy, bool permanent, QDateTime expires) { KSSLCNode *node; for (node = certList.first(); node; node = certList.next()) { if (cert == *(node->cert)) { node->permanent = permanent; node->expires = expires; node->policy = policy; certList.remove(node); certList.prepend(node); cacheSaveToDisk(); return true; } } return false; }
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; }