From ecdecbc8a96f4ea3064b6de64ffa3819c05af1fa Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 7 Oct 2002 21:29:55 +0000 Subject: [PATCH] Wizard changed --- MainWindowX509.cpp | 10 +- NewX509.cpp | 111 ++-- NewX509.h | 4 +- NewX509_UI.ui | 1528 +++++++++++++++++++++++++------------------- lib/pki_x509.cpp | 8 + 5 files changed, 964 insertions(+), 697 deletions(-) diff --git a/MainWindowX509.cpp b/MainWindowX509.cpp index 3e29c253..851bd859 100644 --- a/MainWindowX509.cpp +++ b/MainWindowX509.cpp @@ -82,7 +82,7 @@ void MainWindow::newCert(pki_temp *templ) // Step 1 - Subject and key - if (dlg->fromDataRB->isChecked()) { + if (!dlg->fromReqCB->isChecked()) { clientkey = (pki_key *)keys->getSelectedPKI(dlg->keyList->currentText().latin1()); if (opensslError(clientkey)) goto err; string cn = dlg->commonName->text().latin1(); @@ -230,7 +230,6 @@ void MainWindow::newCert(pki_temp *templ) addStr(certTypeStr, certTypeList[i]); } } - CERR << "IssAltName:" << issAltName<< endl; cert->addV3ext(NID_netscape_cert_type, certTypeStr); cert->addV3ext(NID_netscape_base_url, dlg->nsBaseUrl->text().latin1()); cert->addV3ext(NID_netscape_revocation_url, dlg->nsRevocationUrl->text().latin1()); @@ -245,8 +244,10 @@ void MainWindow::newCert(pki_temp *templ) if (opensslError(cert)) goto err; CERR << "SIGNED" <insertPKI(cert); } @@ -742,7 +744,7 @@ void MainWindow::genCrl() } certs->assignClients(crl); crl->addV3ext(NID_authority_key_identifier,"keyid,issuer"); - crl->addV3ext(NID_issuer_alt_name,"issuer:copy"); + //crl->addV3ext(NID_issuer_alt_name,"issuer:copy"); crl->sign(cert->getKey()); if (!opensslError(crl)) { crl->writeCrl(s.latin1()); diff --git a/NewX509.cpp b/NewX509.cpp index ad2ddd07..33b1ed1d 100644 --- a/NewX509.cpp +++ b/NewX509.cpp @@ -66,6 +66,9 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re bigImg1->setPixmap(*image); bigImg2->setPixmap(*image); bigImg3->setPixmap(*image); + bigImg4->setPixmap(*image); + bigImg5->setPixmap(*image); + bigImg6->setPixmap(*image); nsImg->setPixmap(*ns); } #ifdef qt3 @@ -96,14 +99,13 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re else { keyList->setEnabled(false); genKeyBUT->setEnabled(false); - setAppropriate(page3, false); } // any PKCS#10 requests to be used ? if (reqs) { strings = reqs->getDesc(); if (strings.isEmpty()) { - fromReqRB->setDisabled(true); + fromReqCB->setDisabled(true); } else { reqList->insertStringList(strings); @@ -111,7 +113,7 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re } else { reqList->setEnabled(false); - fromReqRB->setEnabled(false); + fromReqCB->setEnabled(false); } // How about signing certificates ? @@ -126,9 +128,10 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re // suggested from: Andrey Brindeew possibleSigner=(pki_x509 *)certs->getSelectedPKI(); if (possibleSigner && possibleSigner->canSign()) { - //const QString name = possibleSigner->getDescription().c_str(); - //certList->setCurrentText(name); + QString name = possibleSigner->getDescription().c_str(); + certList->setCurrentText(name); foreignSignRB->setChecked(true); + // certList->setEnabled(true); } } } @@ -141,7 +144,7 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re if (temps) { strings = temps->getDesc(); if (strings.isEmpty()) { - setAppropriate(page1,false); + templateBox->setEnabled(false); } else { strings.prepend(tr("Empty Template")); @@ -149,22 +152,21 @@ NewX509::NewX509(QWidget *parent , const char *name, db_key *key, db_x509req *re } } else { - setAppropriate(page1,false); + templateBox->setEnabled(false); } - fromDataRB->setChecked(true); setFinishEnabled(page7,true); setNextEnabled(page2,false); } void NewX509::setRequest() { - setAppropriate(page3, false); setAppropriate(page4, false); setAppropriate(page5, false); setAppropriate(page6, false); finishButton()->setEnabled(true); changeDefault->setEnabled(false); changeDefault->setChecked(false); + signerBox->setEnabled(false); startText=tr("Welcome to the settings for Certificate signing requests.... (needs more prosa)"); endText=tr("You are done with entering all parameters for generating a Certificate signing request..... (needs more prosa)"); tText=tr("Certificate request"); @@ -174,7 +176,6 @@ void NewX509::setRequest() void NewX509::setTemp(pki_temp *temp) { setAppropriate(page1, false); - setAppropriate(page3, false); finishButton()->setEnabled(true); startText=tr("Welcome to the settings for Templates.... (needs more prosa)"); endText=tr("You are done with entering all parameters for generating a Template..... (needs more prosa)"); @@ -203,9 +204,8 @@ void NewX509::setup() setTitle(page0, tText + " Wizard"); setTitle(page1, tText + " template selection"); setTitle(page2, tText + " personal settings"); - setTitle(page3, tText + " signing selection"); setTitle(page4, tText + " X.509 v3 Extensions"); - setTitle(page5, tText + " keyusage setup"); + setTitle(page5, tText + " key usage setup"); setTitle(page6, tText + " Netscape extensions"); setTitle(page7, tText + " Wizard finished"); } @@ -213,7 +213,7 @@ void NewX509::setup() void NewX509::defineTemplate(pki_temp *temp) { setAppropriate(page1,false); - fixtemp = temp; + //fixtemp = temp; fromTemplate(temp); } @@ -312,11 +312,23 @@ void NewX509::toTemplate(pki_temp *temp) temp->pathLen = basicPath->text().toInt(); } - +void NewX509::toggleFromRequest() +{ + if (fromReqCB->isChecked()) { + setAppropriate(page2, false); + reqList->setEnabled(true); + } + else { + setAppropriate(page2, true); + reqList->setEnabled(false); + } +} + + void NewX509::dataChangeP2() { CERR << "Data changed" << endl; - if ((description->text() != "" || fromReqRB->isChecked()) && + if ((description->text() != "" || fromReqCB->isChecked()) && (keyList->count() > 0 || !keyList->isEnabled())){ setNextEnabled(page2,true); } @@ -329,40 +341,51 @@ void NewX509::showPage(QWidget *page) { if (page == page0) { - templateChanged(); + signerChanged(); switchExtended(); + toggleFromRequest(); } else if ( page == page2 ) { dataChangeP2(); - description->setFocus(); } - else if ( page == page3 ) { - if (!selfSignRB->isChecked() && !foreignSignRB->isChecked()) { - if (fromDataRB->isChecked()) { - selfSignRB->setChecked(true); - serialNr->setText("00"); - serialNr->setFocus(); - } - else { - foreignSignRB->setChecked(true); - foreignSignRB->setFocus(); - } - } - else { - if (!foreignSignRB->isEnabled()) { - selfSignRB->setChecked(true); - serialNr->setText("00"); - serialNr->setFocus(); - } - } + + QWizard::showPage(page); + + if ( page == page2 ) { + description->setFocus(); } else if (page == page4) { basicCA->setFocus(); } - QWizard::showPage(page); } +void NewX509::signerChanged() +{ + CERR << "signer Changed" <currentText(); + CERR << "Certificate: " << name.latin1() << endl; + if (name.isEmpty()) return; + pki_x509 *cert = (pki_x509 *)certs->getSelectedPKI(name.latin1()); + if (!cert) return; + QString templ = cert->getTemplate().c_str(); + CERR << "set Template: " << templ.latin1() << endl; + tempList->setCurrentText(templ); + templateChanged(); + /* + QStringList templates = tempList->list(); + for (i=0; i0) { + tempList->setSelected(sel); + }*/ +} + void NewX509::templateChanged() { if (!appropriate(page1)) return; @@ -379,7 +402,7 @@ void NewX509::switchExtended() { if ( !appropriate(page1) ) return; CERR << "SWITCH Extended" <isChecked()) { + if (changeDefault->isChecked() || !templateBox->isEnabled()) { setAppropriate(page4, true); setAppropriate(page5, true); setAppropriate(page6, true); @@ -391,18 +414,6 @@ void NewX509::switchExtended() } } -void NewX509::setDisabled(int state) -{ - if (state == 2) { - inputFrame->setDisabled(false); - reqList->setDisabled(true); - } - else if (state == 0) { - inputFrame->setDisabled(true); - reqList->setDisabled(false); - } -} - void NewX509::newKey() { emit genKey(); diff --git a/NewX509.h b/NewX509.h index 6b7b7328..fd68ac80 100644 --- a/NewX509.h +++ b/NewX509.h @@ -67,6 +67,7 @@ #include #include #include +#include #ifndef NEWX509_H #define NEWX509_H @@ -97,12 +98,13 @@ class NewX509: public NewX509_UI void int2lb(QListBox *lb, int x); public slots: - void setDisabled(int state); + void toggleFromRequest(); void newKey(); void dataChangeP2(); void newKeyDone(QString name); void switchExtended(); void templateChanged(); + void signerChanged(); signals: void genKey(); diff --git a/NewX509_UI.ui b/NewX509_UI.ui index 32ada3e6..adadb123 100644 --- a/NewX509_UI.ui +++ b/NewX509_UI.ui @@ -11,7 +11,7 @@ 0 0 - 592 + 584 520 @@ -299,16 +299,72 @@ - QGroupBox + QLayoutWidget name - templateFrame + Layout12 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + fromReqCB + + + text + Sign this Certificate signing request + + + + QComboBox + + name + reqList + + + + + + + name + Spacer70 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QButtonGroup + + name + signerBox title - Template + Signer - + margin 11 @@ -317,7 +373,93 @@ spacing 6 - + + QRadioButton + + name + foreignSignRB + + + text + Use this Certificate for for signing: + + + + QRadioButton + + name + selfSignRB + + + text + Create a self signed certificate with the serial + + + checked + true + + + + QLineEdit + + name + serialNr + + + + QComboBox + + name + certList + + + enabled + false + + + + + + + name + Spacer69 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QGroupBox + + name + templateBox + + + title + Template + + + + margin + 11 + + + spacing + 6 + + QLabel name @@ -325,17 +467,10 @@ text - Please choose from the templates the one to use for the new certificate or request - - - alignment - WordBreak|AlignVCenter|AlignLeft - - - wordwrap + Template for the new certificate - + QComboBox name @@ -349,7 +484,7 @@ - + QCheckBox name @@ -360,7 +495,7 @@ Change the default extension settings from the template - + @@ -405,398 +540,86 @@ 6 - QLabel + QLayoutWidget name - TextLabel10 + Layout16_3 - - text - For a new certificate you have to enter your personal data into the form and select a key to use. -For signing a request, please select the appropriate Certificates igning request. -For a SSL servercertificate choose the DNS name of the server as "Common name" - - - - QButtonGroup - - name - ButtonGroup1 - - - frameShape - Box - - - frameShadow - Sunken - - - title - Source of the subject and the key - - + margin - 11 + 0 spacing 6 + + + name + Spacer37_4 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + - QRadioButton + QLabel name - fromDataRB + bigImg3 - text - Use the data entered here + minimumSize + + 200 + 94 + + + + scaledContents + true - - QFrame - + + name - inputFrame + Spacer38_4 - sizePolicy - - 5 - 5 - + orientation + Horizontal - frameShape - Box + sizeType + Expanding - - frameShadow - Sunken + + sizeHint + + 20 + 20 + - - - margin - 11 - - - spacing - 6 - - - - name - Spacer6_2 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLineEdit - - name - stateOrProvinceName - - - - QLabel - - name - TextLabel7_2 - - - text - E-Mail address: - - - - QLineEdit - - name - organisationalUnitName - - - - QLabel - - name - TextLabel4_2_2 - - - text - Organisation: - - - - QLabel - - name - TextLabel3_2 - - - text - State or Province - - - - QLineEdit - - name - organisationName - - - text - - - - - QLabel - - name - TextLabel5_2 - - - text - Organisational unit: - - - - QComboBox - - name - keyList - - - - QPushButton - - name - genKeyBUT - - - text - Generate a new key - - - - QLineEdit - - name - description - - - - QLineEdit - - name - localityName - - - text - - - - - - name - Spacer5_2 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLabel - - name - TextLabel6_2 - - - text - Common name: - - - - QLineEdit - - name - countryName - - - sizePolicy - - 1 - 0 - - - - - QLabel - - name - TextLabel1_2_3 - - - text - Key: - - - - QLabel - - name - TextLabel4_3 - - - text - Locality: - - - - QLabel - - name - TextLabel2_2 - - - text - Country: - - - - QLabel - - name - TextLabel1_3_2 - - - text - Certificate name: - - - - QLineEdit - - name - emailAddress - - - - QLineEdit - - name - commonName - - - - - - QLayoutWidget - - name - Layout7_2 - - - - margin - 0 - - - spacing - 6 - - - QRadioButton - - name - fromReqRB - - - text - Use this Certificate signing request - - - - QComboBox - - name - reqList - - - - - - - - - - QWidget - - name - page3 - - - title - - - - - margin - 11 - - - spacing - 6 - - - QLabel - - name - TextLabel10_2 - - - text - Please choose the signer, wether it should be self signed, or signed by an other signer - - - alignment - WordBreak|AlignVCenter|AlignLeft - - - wordwrap - + + name - Spacer14 + Spacer71 orientation @@ -815,14 +638,48 @@ For a SSL servercertificate choose the DNS name of the server as "Common name" - QButtonGroup + QLabel name - ButtonGroup2 + TextLabel10 + + + text + For a new certificate you have to enter your personal data into the form and select a key to use. +For signing a request, please select the appropriate Certificates igning request. +For a SSL servercertificate choose the DNS name of the server as "Common name" + + + + + name + Spacer72 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QGroupBox + + name + GroupBox17 title - Certificate to sign with + Source of the subject and the key @@ -833,40 +690,192 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"spacing 6 - - QComboBox - - name - certList - - - - QRadioButton - - name - foreignSignRB - - - text - Use this Certificate for for signing: - - - + QLineEdit name - serialNr + stateOrProvinceName - - QRadioButton + + QLabel name - selfSignRB + TextLabel7_2 text - Create a self signed certificate with the serial: + E-Mail address: + + + + QLineEdit + + name + organisationalUnitName + + + + QLabel + + name + TextLabel3_2 + + + text + State or Province + + + + QLineEdit + + name + organisationName + + + text + + + + + QLabel + + name + TextLabel5_2 + + + text + Organisational unit: + + + + QComboBox + + name + keyList + + + + QLineEdit + + name + description + + + + QLineEdit + + name + localityName + + + text + + + + + QLabel + + name + TextLabel6_2 + + + text + Common name: + + + + QLineEdit + + name + countryName + + + sizePolicy + + 1 + 0 + + + + + QLabel + + name + TextLabel1_2_3 + + + text + Key: + + + + QLabel + + name + TextLabel4_3 + + + text + Locality: + + + + QLabel + + name + TextLabel2_2 + + + text + Country: + + + + QLabel + + name + TextLabel1_3_2 + + + text + Certificate name: + + + + QLineEdit + + name + emailAddress + + + + QLineEdit + + name + commonName + + + + QLabel + + name + TextLabel4_2_2 + + + text + Organisation: + + + + QPushButton + + name + genKeyBUT + + + text + Generate a new key @@ -874,7 +883,7 @@ For a SSL servercertificate choose the DNS name of the server as "Common name" name - Spacer15 + Spacer73 orientation @@ -913,6 +922,83 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"spacing 6 + + QLayoutWidget + + name + Layout16_3_2 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer37_4_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + bigImg4 + + + minimumSize + + 200 + 94 + + + + scaledContents + true + + + + + name + Spacer38_4_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + name @@ -1256,6 +1342,27 @@ For a SSL servercertificate choose the DNS name of the server as "Common name" + + + name + Spacer74 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + @@ -1268,7 +1375,7 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"title Page - + margin 11 @@ -1277,213 +1384,349 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"spacing 6 - - QGroupBox + + QLayoutWidget name - GroupBox4 + Layout16_3_3 - - title - Key Usage - - + margin - 11 + 0 + + + spacing + 6 + + + + name + Spacer37_4_3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + bigImg5 + + + minimumSize + + 200 + 94 + + + + scaledContents + true + + + + + name + Spacer38_4_3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer79 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout15 + + + + margin + 0 spacing 6 - QCheckBox + QGroupBox name - kuCritical + GroupBox4 - text - Critical + title + Key Usage + + + margin + 11 + + + spacing + 6 + + + QCheckBox + + name + kuCritical + + + text + Critical + + + + QListBox + + + text + Digital Signature + + + + + text + Non Repudiation + + + + + text + Key Encipherment + + + + + text + Data Encipherment + + + + + text + Key Agreement + + + + + text + Certificate Sign + + + + + text + CRL Sign + + + + + text + Encipher Only + + + + + text + Decipher Only + + + + name + keyUsage + + + selectionMode + Multi + + + - QListBox - - - text - Digital Signature - - - - - text - Non Repudiation - - - - - text - Key Encipherment - - - - - text - Data Encipherment - - - - - text - Key Agreement - - - - - text - Certificate Sign - - - - - text - CRL Sign - - - - - text - Encipher Only - - - - - text - Decipher Only - - + QGroupBox name - keyUsage + GroupBox5 - selectionMode - Multi + title + Extended Key Usage + + + margin + 11 + + + spacing + 6 + + + QCheckBox + + name + ekuCritical + + + text + Critical + + + + QListBox + + + text + SSL/TLS Web Server Authentication + + + + + text + SSL/TLS Web Client Authentication + + + + + text + Code signing + + + + + text + E-mail Protection (S/MIME) + + + + + text + Trusted Timestamping + + + + + text + Microsoft Individual Code Signing (authenticode) + + + + + text + Microsoft Commercial Code Signing (authenticode) + + + + + text + Microsoft Trust List Signing + + + + + text + Microsoft Server Gated Crypto + + + + + text + Microsoft Encrypted File System + + + + + text + Netscape Server Gated Crypto + + + + name + ekeyUsage + + + selectionMode + Multi + + + - + - - QGroupBox - + + name - GroupBox5 + Spacer80 - title - Extended Key Usage + orientation + Vertical - - - margin - 11 - - - spacing - 6 - - - QCheckBox - - name - ekuCritical - - - text - Critical - - - - QListBox - - - text - SSL/TLS Web Server Authentication - - - - - text - SSL/TLS Web Client Authentication - - - - - text - Code signing - - - - - text - E-mail Protection (S/MIME) - - - - - text - Trusted Timestamping - - - - - text - Microsoft Individual Code Signing (authenticode) - - - - - text - Microsoft Commercial Code Signing (authenticode) - - - - - text - Microsoft Trust List Signing - - - - - text - Microsoft Server Gated Crypto - - - - - text - Microsoft Encrypted File System - - - - - text - Netscape Server Gated Crypto - - - - name - ekeyUsage - - - selectionMode - Multi - - - - - + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + QWidget @@ -1679,38 +1922,6 @@ For a SSL servercertificate choose the DNS name of the server as "Common name" - - Line - - name - Line1 - - - orientation - Horizontal - - - - - name - Spacer40 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - QLayoutWidget @@ -1854,6 +2065,27 @@ For a SSL servercertificate choose the DNS name of the server as "Common name" + + + name + Spacer40 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + @@ -1915,7 +2147,7 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"QLabel name - bigImg3 + bigImg6 minimumSize @@ -2011,12 +2243,6 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"NewX509_UI newKey() - - fromDataRB - stateChanged(int) - NewX509_UI - setDisabled(int) - description textChanged(const QString&) @@ -2029,12 +2255,6 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"NewX509_UI switchExtended() - - fromReqRB - toggled(bool) - NewX509_UI - dataChangeP2() - keyList textChanged(const QString&) @@ -2047,11 +2267,42 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"NewX509_UI templateChanged() - templateChanged() + + fromReqCB + clicked() + NewX509_UI + toggleFromRequest() + + + selfSignRB + toggled(bool) + serialNr + setEnabled(bool) + + + foreignSignRB + toggled(bool) + certList + setEnabled(bool) + + + certList + activated(int) + NewX509_UI + signerChanged() + + + foreignSignRB + clicked() + NewX509_UI + signerChanged() + dataChangeP2() newKey() - setDisabled(int) + signerChanged() switchExtended() + templateChanged() + toggleFromRequest() tempList @@ -2066,12 +2317,6 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"emailAddress keyList genKeyBUT - fromReqRB - reqList - selfSignRB - serialNr - foreignSignRB - certList bcCritical basicCA basicPath @@ -2088,6 +2333,5 @@ For a SSL servercertificate choose the DNS name of the server as "Common name"keyUsage ekuCritical ekeyUsage - fromDataRB diff --git a/lib/pki_x509.cpp b/lib/pki_x509.cpp index 742ad9e8..fca628e3 100644 --- a/lib/pki_x509.cpp +++ b/lib/pki_x509.cpp @@ -95,6 +95,7 @@ pki_x509::pki_x509(string d,pki_key *clientKey, pki_x509req *req, pki_x509 *sign caSerial=0; caTemplate=""; crlDays=30; + lastCrl= NULL; } pki_x509::pki_x509(X509 *c) : pki_base() @@ -183,6 +184,9 @@ pki_x509::~pki_x509() if (revoked) { ASN1_TIME_free(revoked); } + if (lastCrl) { + ASN1_TIME_free(lastCrl); + } } @@ -289,10 +293,14 @@ bool pki_x509::fromData(unsigned char *p, int size) unsigned char *pki_x509::toData(int *size) { #define PKI_DB_VERSION (int)3 + CERR <<"cert toData" << endl; unsigned char *p, *p1; int sCert = i2d_X509(cert, NULL); + CERR << "A" <