Ejemplo n.º 1
0
void KSSLD::cacheSaveToDisk() {
  KSSLCNode *node;

  for (node = certList.first(); node; node = certList.next()) {
    if (node->permanent || node->expires > QDateTime::currentDateTime()) {
      // First convert to a binary format and then write the kconfig entry
      // write the (CN, policy, cert) to KSimpleConfig
      cfg->setGroup(node->cert->getSubject());
      cfg->writeEntry("Certificate", node->cert->toString());
      cfg->writeEntry("Policy", node->policy);
      cfg->writeEntry("Expires", node->expires);
      cfg->writeEntry("Permanent", node->permanent);
      cfg->writeEntry("Hosts", node->hosts);
      // Also write the chain
      QStringList qsl;
      QPtrList<KSSLCertificate> cl = node->cert->chain().getChain();
      for (KSSLCertificate *c = cl.first(); c != 0; c = cl.next()) {
         //kdDebug() << "Certificate in chain: " <<  c->toString() << endl;
         qsl << c->toString();
      }
      cl.setAutoDelete(true);
      cfg->writeEntry("Chain", qsl);
    }
  }  

  cfg->sync();

  // insure proper permissions -- contains sensitive data
  QString cfgName(KGlobal::dirs()->findResource("config", "ksslpolicies"));
  if (!cfgName.isEmpty())
    ::chmod(QFile::encodeName(cfgName), 0600);
}
Ejemplo n.º 2
0
void KSSLD::cacheLoadDefaultPolicies() {
  QStringList groups = cfg->groupList();

  for (QStringList::Iterator i = groups.begin();
                             i != groups.end();
                             ++i) {
    if ((*i).length() == 0) continue;
    cfg->setGroup(*i);

    // remove it if it has expired
    if (!cfg->readBoolEntry("Permanent") && cfg->readDateTimeEntry("Expires") < QDateTime::currentDateTime()) {
       cfg->deleteGroup(*i);
       continue;
    }

    QCString encodedCert = cfg->readEntry("Certificate").local8Bit();
    KSSLCertificate *newCert = KSSLCertificate::fromString(encodedCert);
    if (!newCert) continue;
    KSSLCNode *n = new KSSLCNode;
    n->cert = newCert;
    n->policy = (KSSLCertificateCache::KSSLCertificatePolicy)
                cfg->readNumEntry("Policy");
    n->permanent = cfg->readBoolEntry("Permanent");
    n->expires = cfg->readDateTimeEntry("Expires");
    n->hosts = cfg->readListEntry("Hosts");
    newCert->chain().setChain(cfg->readListEntry("Chain"));
    certList.append(n); 
  }
}
Ejemplo n.º 3
0
KSSLCertificate KSSLD::getCertByMD5Digest(const TQString &key) {
	TQMap<TQString, KSSLCertificate *>::iterator iter = skMD5Digest.find(key);
	
	kdDebug() << "Searching cert for " << key.latin1() << endl;

	if (iter != skMD5Digest.end())
		return **iter;
	
	KSSLCertificate rc; // FIXME: Better way to return a not found condition?
	kdDebug() << "Not found: " << rc.toString().latin1() << endl;
	return rc;
}	
Ejemplo n.º 4
0
static void updatePoliciesConfig(KConfig *cfg)
{
    QStringList groups = cfg->groupList();

    for(QStringList::Iterator i = groups.begin(); i != groups.end(); ++i)
    {
        if((*i).isEmpty() || *i == "General")
        {
            continue;
        }

        cfg->setGroup(*i);

        // remove it if it has expired
        if(!cfg->readBoolEntry("Permanent") && cfg->readDateTimeEntry("Expires") < QDateTime::currentDateTime())
        {
            cfg->deleteGroup(*i);
            continue;
        }

        QString encodedCertStr = cfg->readEntry("Certificate");
        QCString encodedCert = encodedCertStr.local8Bit();
        KSSLCertificate *newCert = KSSLCertificate::fromString(encodedCert);
        if(!newCert)
        {
            cfg->deleteGroup(*i);
            continue;
        }

        KSSLCertificateCache::KSSLCertificatePolicy policy = (KSSLCertificateCache::KSSLCertificatePolicy)cfg->readNumEntry("Policy");
        bool permanent = cfg->readBoolEntry("Permanent");
        QDateTime expires = cfg->readDateTimeEntry("Expires");
        QStringList hosts = cfg->readListEntry("Hosts");
        QStringList chain = cfg->readListEntry("Chain");
        cfg->deleteGroup(*i);

        cfg->setGroup(newCert->getMD5Digest());
        cfg->writeEntry("Certificate", encodedCertStr);
        cfg->writeEntry("Policy", policy);
        cfg->writeEntry("Permanent", permanent);
        cfg->writeEntry("Expires", expires);
        cfg->writeEntry("Hosts", hosts);
        cfg->writeEntry("Chain", chain);
        delete newCert;
    }

    cfg->setGroup("General");
    cfg->writeEntry("policies version", 2);

    cfg->sync();
}
Ejemplo n.º 5
0
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();
}
Ejemplo n.º 6
0
bool KSSLD::caAdd(TQString certificate, bool ssl, bool email, bool code) {
KSSLCertificate *x = KSSLCertificate::fromString(certificate.local8Bit());

	if (!x) return false;

TDEConfig cfg("ksslcalist", false, false);

	cfg.setGroup(x->getSubject());
	cfg.writeEntry("x509", certificate);
	cfg.writeEntry("site", ssl);
	cfg.writeEntry("email", email);
	cfg.writeEntry("code", code);

	cfg.sync();
	delete x;

return true;
}
Ejemplo n.º 7
0
void KSSLInfoDlg::slotChain(int x)
{
    if(x == 0)
    {
        displayCert(d->_cert);
    }
    else
    {
        QPtrList< KSSLCertificate > cl = d->_cert->chain().getChain();
        cl.setAutoDelete(true);
        for(int i = 0; i < x - 1; i++)
            cl.remove((unsigned int)0);
        KSSLCertificate thisCert = *(cl.at(0));
        cl.remove((unsigned int)0);
        thisCert.chain().setChain(cl);
        displayCert(&thisCert);
    }
}
Ejemplo n.º 8
0
void UIServer::showSSLInfoDialog(const QString &url, const KIO::MetaData &meta, int mainwindow)
{
    KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true);
    KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit());
    if(x)
    {
        // Set the chain back onto the certificate
        QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]);
        QPtrList< KSSLCertificate > ncl;

        ncl.setAutoDelete(true);
        for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it)
        {
            KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit());
            if(y)
                ncl.append(y);
        }

        if(ncl.count() > 0)
            x->chain().setChain(ncl);

        kdDebug(7024) << "ssl_cert_errors=" << meta["ssl_cert_errors"] << endl;
        kid->setCertState(meta["ssl_cert_errors"]);
        QString ip = meta.contains("ssl_proxied") ? "" : meta["ssl_peer_ip"];
        kid->setup(x, ip,
                   url, // the URL
                   meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(),
                   meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt()));
        kdDebug(7024) << "Showing SSL Info dialog" << endl;

        if(mainwindow != 0)
            KWin::setMainWindow(kid, mainwindow);

        kid->exec();
        delete x;
        kdDebug(7024) << "SSL Info dialog closed" << endl;
    }
    else
    {
        KMessageBox::information(0L, // parent ?
                                 i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL"));
    }
    // Don't delete kid!!
}
Ejemplo n.º 9
0
bool KSSLD::caRemoveFromFile(TQString filename) {

	TQStringList certificates;
	certificates = caReadCerticatesFromFile(filename);
	if (certificates.isEmpty())
		return false;

	bool ok = true;

	for (TQStringList::Iterator it = certificates.begin();
					it != certificates.end(); ++it ) {
		TQString certificate = *it;
		KSSLCertificate *x = KSSLCertificate::fromString(certificate.local8Bit());
		ok &= x && caRemove(x->getSubject());
		delete x;
	}

	return ok;
}
Ejemplo n.º 10
0
TQStringList KSSLD::getKDEKeyByEmail(const TQString &email) {
	TQStringList rc;
	TQMap<TQString, TQPtrVector<KSSLCertificate> >::iterator it = skEmail.find(email.lower());

	kdDebug() << "GETKDEKey " << email.latin1() << endl;

	if (it == skEmail.end())
		return rc;

	TQPtrVector<KSSLCertificate> &elem = *it;
	for (unsigned int n = 0; n < elem.size(); n++) {
		KSSLCertificate *cert = elem.at(n);
		if (cert) {
			rc.append(cert->getKDEKey());
		}
	}

	kdDebug() << "ergebnisse: " << rc.size() << " " << elem.size() << endl;
	return rc;
}
Ejemplo n.º 11
0
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();
}
Ejemplo n.º 12
0
void KJavaAppletServer::slotJavaRequest( const QByteArray& qb )
{
    // qb should be one command only without the length string,
    // we parse out the command and it's meaning here...
    QString cmd;
    QStringList args;
    int index = 0;
    const int qb_size = qb.size();

    //get the command code
    const char cmd_code = qb[ index++ ];
    ++index; //skip the next sep

    //get contextID
    QString contextID;
    while( qb[index] != 0 && index < qb_size )
    {
        contextID += qb[ index++ ];
    }
    bool ok;
    const int ID_num = contextID.toInt( &ok ); // context id or kio job id
    /*if (d->locked_context > -1 &&
        ID_num != d->locked_context &&
        (cmd_code == KJAS_JAVASCRIPT_EVENT ||
         cmd_code == KJAS_APPLET_STATE ||
         cmd_code == KJAS_APPLET_FAILED))
    {
        / * Don't allow requests from other contexts if we're waiting
         * on a return value that can trigger JavaScript events
         * /
        d->java_requests.push_back(qb);
        return;
    }*/
    ++index; //skip the sep

    if (cmd_code == KJAS_PUT_DATA) {
        // rest of the data is for kio put
        if (ok) {
            KIOJobMap::iterator it = d->kiojobs.find( ID_num );
            if (ok && it != d->kiojobs.end()) {
                QByteArray qba;
                qba = QByteArray::fromRawData(qb.data() + index, qb.size() - index - 1);
                it.value()->data(qba);
                qba = QByteArray::fromRawData(qb.data() + index, qb.size() - index - 1);
            }
            kDebug(6100) << "PutData(" << ID_num << ") size=" << qb.size() - index;
        } else
            kError(6100) << "PutData error " << ok << endl;
        return;
    }
    //now parse out the arguments
    while( index < qb_size )
    {
        int sep_pos = qb.indexOf( (char) 0, index );
        if (sep_pos < 0) {
            kError(6100) << "Missing separation byte" << endl;
            sep_pos = qb_size;
        }
        //kDebug(6100) << "KJavaAppletServer::slotJavaRequest: "<< QString::fromLocal8Bit( qb.data() + index, sep_pos - index );
        args.append( QString::fromLocal8Bit( qb.data() + index, sep_pos - index ) );
        index = sep_pos + 1; //skip the sep
    }
    //here I should find the context and call the method directly
    //instead of emitting signals
    switch( cmd_code )
    {
        case KJAS_SHOW_DOCUMENT:
            cmd = QLatin1String( "showdocument" );
            break;

        case KJAS_SHOW_URLINFRAME:
            cmd = QLatin1String( "showurlinframe" );
            break;

        case KJAS_SHOW_STATUS:
            cmd = QLatin1String( "showstatus" );
            break;

        case KJAS_RESIZE_APPLET:
            cmd = QLatin1String( "resizeapplet" );
            break;

        case KJAS_GET_URLDATA:
            if (ok && !args.empty() ) {
                d->kiojobs.insert(ID_num, new KJavaDownloader(ID_num, args.first()));
                kDebug(6100) << "GetURLData(" << ID_num << ") url=" << args.first();
            } else
                kError(6100) << "GetURLData error " << ok << " args:" << args.size() << endl;
            return;
        case KJAS_PUT_URLDATA:
            if (ok && !args.empty()) {
                KJavaUploader* const job = new KJavaUploader(ID_num, args.first());
                d->kiojobs.insert(ID_num, job);
                job->start();
                kDebug(6100) << "PutURLData(" << ID_num << ") url=" << args.first();
            } else
                kError(6100) << "PutURLData error " << ok << " args:" << args.size() << endl;
            return;
        case KJAS_DATA_COMMAND:
            if (ok && !args.empty()) {
                const int cmd = args.first().toInt( &ok );
                KIOJobMap::iterator it = d->kiojobs.find( ID_num );
                if (ok && it != d->kiojobs.end())
                    it.value()->jobCommand( cmd );
                kDebug(6100) << "KIO Data command: " << ID_num << " " << args.first();
            } else
                kError(6100) << "KIO Data command error " << ok << " args:" << args.size() << endl;
            return;
        case KJAS_JAVASCRIPT_EVENT:
            cmd = QLatin1String( "JS_Event" );

            if(!args.empty()) {
                 kDebug(6100) << "Javascript request: "<< contextID
                              << " code: " << args[0] << endl;
            } else {
                kError(6100) << "Expected args not to be empty!" << endl;
            }

            break;
        case KJAS_GET_MEMBER:
        case KJAS_PUT_MEMBER:
        case KJAS_CALL_MEMBER: {
            if(!args.empty()) {
                const int ticket = args[0].toInt();
                JSStack::iterator it = d->jsstack.find(ticket);
                if (it != d->jsstack.end()) {
                    kDebug(6100) << "slotJavaRequest: " << ticket;
                    args.pop_front();
                    it.value()->args.operator=(args); // just in case ..
                    it.value()->ready = true;
                    it.value()->exit = true;
                } else
                    kDebug(6100) << "Error: Missed return member data";
            } else {
                kError(6100) << "Expected args not to be empty!" << endl;
            }
            return;
        }
        case KJAS_AUDIOCLIP_PLAY:
            cmd = QLatin1String( "audioclip_play" );
            if(!args.empty())
                kDebug(6100) << "Audio Play: url=" << args[0];
            else
                kError(6100) << "Expected args not to be empty!" << endl;

            break;
        case KJAS_AUDIOCLIP_LOOP:
            cmd = QLatin1String( "audioclip_loop" );
            if(!args.empty())
                kDebug(6100) << "Audio Loop: url=" << args[0];
            else
                kError(6100) << "Expected args not to be empty!" << endl;

            break;
        case KJAS_AUDIOCLIP_STOP:
            cmd = QLatin1String( "audioclip_stop" );
            if(!args.empty())
                kDebug(6100) << "Audio Stop: url=" << args[0];
            else
                kError(6100) << "Expected args not to be empty!" << endl;

            break;
        case KJAS_APPLET_STATE:
            if(args.size() > 1)
                kDebug(6100) << "Applet State Notification for Applet " << args[0] << ". New state=" << args[1];
            else
                kError(6100) << "Expected args not to be empty!" << endl;

            cmd = QLatin1String( "AppletStateNotification" );
            break;
        case KJAS_APPLET_FAILED:
            if(args.size() > 1)
                kDebug(6100) << "Applet " << args[0] << " Failed: " << args[1];
            else
                kError(6100) << "Expected args not to be empty!" << endl;

            cmd = QLatin1String( "AppletFailed" );
            break;
        case KJAS_SECURITY_CONFIRM: {
            if (KSSL::doesSSLWork() && !d->kssl)
                d->kssl = new KSSL;
            QStringList sl;
            QString answer( "invalid" );

            if (!d->kssl) {
                answer = "nossl";
            } else if (args.size() > 2) {
                const int certsnr = args[1].toInt();
                Q_ASSERT(args.size() > certsnr + 1);
                QString text;
                QList<KSSLCertificate *> certs;
                for (int i = certsnr - 1; i >= 0; --i) {
                    const QByteArray &arg = args[i + 2].toAscii();
                    KSSLCertificate * cert = KSSLCertificate::fromString(arg.constData());
                    if (cert) {
                        certs.prepend(cert);
                        if (cert->isSigner())
                            text += i18n("Signed by (validation: %1)", KSSLCertificate::verifyText(cert->validate()));
                        else
                            text += i18n("Certificate (validation: %1)", KSSLCertificate::verifyText(cert->validate()));
                        text += "\n";
                        QString subject = cert->getSubject() + QChar('\n');
                        QRegExp reg(QString("/[A-Z]+="));
                        int pos = 0;
                        while ((pos = subject.indexOf(reg, pos)) > -1)
                            subject.replace(pos, 1, QString("\n    "));
                        text += subject.mid(1);
                    }
                }
                kDebug(6100) << "Security confirm " << args.first() << certs.count();
                if ( !certs.isEmpty() ) {
                    KSSLCertChain chain;
                    chain.setChain( certs );
                    if ( chain.isValid() )
                        answer = PermissionDialog( qApp->activeWindow() ).exec( text, args[0] );
                }
                qDeleteAll(certs);
            }
            sl.push_front( answer );
            sl.push_front( QString::number(ID_num) );
            process->send( KJAS_SECURITY_CONFIRM, sl );
            return;
        }
        default:
            return;
            break;
    }


    if( !ok )
    {
        kError(6100) << "could not parse out contextID to call command on" << endl;
        return;
    }

    KJavaAppletContext* const context = d->contexts[ ID_num ];
    if( context )
        context->processCmd( cmd, args );
    else if (cmd != "AppletStateNotification")
        kError(6100) << "no context object for this id" << endl;
}
Ejemplo n.º 13
0
int Observer::messageBox(int progressId, int type, const QString &text, const QString &caption, const QString &buttonYes, const QString &buttonNo,
                         const QString &dontAskAgainName)
{
    kdDebug() << "Observer::messageBox " << type << " " << text << " - " << caption << endl;
    int result = -1;
    KConfig *config = new KConfig("kioslaverc");
    KMessageBox::setDontShowAskAgainConfig(config);

    switch(type)
    {
        case KIO::SlaveBase::QuestionYesNo:
            result = KMessageBox::questionYesNo(0L, // parent ?
                                                text, caption, buttonYes, buttonNo, dontAskAgainName);
            break;
        case KIO::SlaveBase::WarningYesNo:
            result = KMessageBox::warningYesNo(0L, // parent ?
                                               text, caption, buttonYes, buttonNo, dontAskAgainName);
            break;
        case KIO::SlaveBase::WarningContinueCancel:
            result = KMessageBox::warningContinueCancel(0L, // parent ?
                                                        text, caption, buttonYes, dontAskAgainName);
            break;
        case KIO::SlaveBase::WarningYesNoCancel:
            result = KMessageBox::warningYesNoCancel(0L, // parent ?
                                                     text, caption, buttonYes, buttonNo, dontAskAgainName);
            break;
        case KIO::SlaveBase::Information:
            KMessageBox::information(0L, // parent ?
                                     text, caption, dontAskAgainName);
            result = 1; // whatever
            break;
        case KIO::SlaveBase::SSLMessageBox:
        {
            QCString observerAppId = caption.utf8(); // hack, see slaveinterface.cpp
            // Contact the object "KIO::Observer" in the application <appId>
            // Yes, this could be the same application we are, but not necessarily.
            Observer_stub observer(observerAppId, "KIO::Observer");

            KIO::MetaData meta = observer.metadata(progressId);
            KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true);
            KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit());
            if(x)
            {
                // Set the chain back onto the certificate
                QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]);
                QPtrList< KSSLCertificate > ncl;

                ncl.setAutoDelete(true);
                for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it)
                {
                    KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit());
                    if(y)
                        ncl.append(y);
                }

                if(ncl.count() > 0)
                    x->chain().setChain(ncl);

                kid->setup(x, meta["ssl_peer_ip"],
                           text, // the URL
                           meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(),
                           meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt()));
                kdDebug(7024) << "Showing SSL Info dialog" << endl;
                kid->exec();
                delete x;
                kdDebug(7024) << "SSL Info dialog closed" << endl;
            }
            else
            {
                KMessageBox::information(0L, // parent ?
                                         i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL"));
            }
            // This doesn't have to get deleted.  It deletes on it's own.
            result = 1; // whatever
            break;
        }
        default:
            kdWarning() << "Observer::messageBox: unknown type " << type << endl;
            result = 0;
            break;
    }
    KMessageBox::setDontShowAskAgainConfig(0);
    delete config;
    return result;
#if 0
    QByteArray data, replyData;
    QCString replyType;
    QDataStream arg( data, IO_WriteOnly );
    arg << progressId;
    arg << type;
    arg << text;
    arg << caption;
    arg << buttonYes;
    arg << buttonNo;
    if ( kapp->dcopClient()->call( "kio_uiserver", "UIServer", "messageBox(int,int,QString,QString,QString,QString)", data, replyType, replyData, true )
        && replyType == "int" )
    {
        int result;
        QDataStream _reply_stream( replyData, IO_ReadOnly );
        _reply_stream >> result;
        kdDebug(KDEBUG_OBSERVER) << "Observer::messageBox got result " << result << endl;
        return result;
    }
Ejemplo n.º 14
0
bool KSSLSigners::addCA(KSSLCertificate& cert,
                        bool ssl,
                        bool email,
                        bool code) const {
	return addCA(cert.toString(), ssl, email, code);
}
Ejemplo n.º 15
0
void KSSLInfoDlg::setup(KSSLCertificate *cert, const QString &ip, const QString &url, const QString &cipher, const QString &cipherdesc,
                        const QString &sslversion, int usedbits, int bits, KSSLCertificate::KSSLValidation /*certState*/)
{
    // Needed to put the GUI stuff here to get the layouting right

    d->_cert = cert;

    QGridLayout *layout = new QGridLayout(4, 2, KDialog::spacingHint());

    layout->addWidget(new QLabel(i18n("Chain:"), this), 0, 0);
    d->_chain = new KComboBox(this);
    layout->addMultiCellWidget(d->_chain, 1, 1, 0, 1);
    connect(d->_chain, SIGNAL(activated(int)), this, SLOT(slotChain(int)));

    d->_chain->clear();

    if(cert->chain().isValid() && cert->chain().depth() > 1)
    {
        d->_chain->setEnabled(true);
        d->_chain->insertItem(i18n("0 - Site Certificate"));
        int cnt = 0;
        QPtrList< KSSLCertificate > cl = cert->chain().getChain();
        cl.setAutoDelete(true);
        for(KSSLCertificate *c = cl.first(); c != 0; c = cl.next())
        {
            KSSLX509Map map(c->getSubject());
            QString id;
            id = map.getValue("CN");
            if(id.length() == 0)
                id = map.getValue("O");
            if(id.length() == 0)
                id = map.getValue("OU");
            d->_chain->insertItem(QString::number(++cnt) + " - " + id);
        }
        d->_chain->setCurrentItem(0);
    }
    else
        d->_chain->setEnabled(false);

    layout->addWidget(new QLabel(i18n("Peer certificate:"), this), 2, 0);
    layout->addWidget(d->_subject = static_cast< KSSLCertBox * >(buildCertInfo(cert->getSubject())), 3, 0);
    layout->addWidget(new QLabel(i18n("Issuer:"), this), 2, 1);
    layout->addWidget(d->_issuer = static_cast< KSSLCertBox * >(buildCertInfo(cert->getIssuer())), 3, 1);
    d->m_layout->addMultiCell(layout, 1, 1, 0, 2);

    layout = new QGridLayout(11, 2, KDialog::spacingHint());
    layout->setColStretch(1, 1);
    QLabel *ipl = new QLabel(i18n("IP address:"), this);
    layout->addWidget(ipl, 0, 0);
    if(ip.isEmpty())
    {
        ipl->hide();
    }
    layout->addWidget(ipl = new QLabel(ip, this), 0, 1);
    if(ip.isEmpty())
    {
        ipl->hide();
    }
    layout->addWidget(new QLabel(i18n("URL:"), this), 1, 0);
    KSqueezedTextLabel *urlLabel = new KSqueezedTextLabel(url, this);
    layout->addWidget(urlLabel, 1, 1);
    layout->addWidget(new QLabel(i18n("Certificate state:"), this), 2, 0);

    layout->addWidget(d->_csl = new QLabel("", this), 2, 1);

    update();

    layout->addWidget(new QLabel(i18n("Valid from:"), this), 3, 0);
    layout->addWidget(d->_validFrom = new QLabel("", this), 3, 1);
    layout->addWidget(new QLabel(i18n("Valid until:"), this), 4, 0);
    layout->addWidget(d->_validUntil = new QLabel("", this), 4, 1);

    layout->addWidget(new QLabel(i18n("Serial number:"), this), 5, 0);
    layout->addWidget(d->_serialNum = new QLabel("", this), 5, 1);
    layout->addWidget(new QLabel(i18n("MD5 digest:"), this), 6, 0);
    layout->addWidget(d->_digest = new QLabel("", this), 6, 1);

    layout->addWidget(new QLabel(i18n("Cipher in use:"), this), 7, 0);
    layout->addWidget(new QLabel(cipher, this), 7, 1);
    layout->addWidget(new QLabel(i18n("Details:"), this), 8, 0);
    layout->addWidget(new QLabel(cipherdesc.simplifyWhiteSpace(), this), 8, 1);
    layout->addWidget(new QLabel(i18n("SSL version:"), this), 9, 0);
    layout->addWidget(new QLabel(sslversion, this), 9, 1);
    layout->addWidget(new QLabel(i18n("Cipher strength:"), this), 10, 0);
    layout->addWidget(new QLabel(i18n("%1 bits used of a %2 bit cipher").arg(usedbits).arg(bits), this), 10, 1);
    d->m_layout->addMultiCell(layout, 2, 2, 0, 2);

    displayCert(cert);
}
Ejemplo n.º 16
0
bool KSSLSigners::remove(KSSLCertificate& cert) {
	return remove(cert.getSubject());
}
Ejemplo n.º 17
0
bool KSSLSigners::useForCode(KSSLCertificate& cert) const{
	return useForCode(cert.getSubject());
}