mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
add the "no well-defined date" from RFC 5280 as checkbox
This commit is contained in:
parent
47e2f6175f
commit
467295e8ca
@ -10,6 +10,7 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <qobject.h>
|
||||
|
||||
a1time::a1time()
|
||||
{
|
||||
@ -73,29 +74,31 @@ a1time &a1time::set(int y, int mon, int d, int h, int m, int s)
|
||||
return set(gt);
|
||||
}
|
||||
|
||||
/* As defined in rfc-5280 4.1.2.5 */
|
||||
#define UNDEFINED_DATE "99991231235959Z"
|
||||
|
||||
QString a1time::toPretty() const
|
||||
{
|
||||
QString t = "";
|
||||
if (!time) return t;
|
||||
BIO * bio = BIO_new(BIO_s_mem());
|
||||
if (!time)
|
||||
return QString();
|
||||
if (QString::fromAscii((char*)time->data, time->length) == UNDEFINED_DATE)
|
||||
return QObject::tr("Undefined");
|
||||
|
||||
char buf[200];
|
||||
BIO * bio = BIO_new(BIO_s_mem());
|
||||
ASN1_TIME_print(bio, time);
|
||||
BIO_gets(bio, buf, 200);
|
||||
t = buf;
|
||||
BIO_free(bio);
|
||||
return t;
|
||||
return QString(buf);
|
||||
}
|
||||
|
||||
QString a1time::toPlain() const
|
||||
{
|
||||
QString t = "";
|
||||
char b[15];
|
||||
if (!time) return t;
|
||||
memcpy(b, time->data, time->length);
|
||||
b[time->length] = '\0';
|
||||
t = b;
|
||||
return t;
|
||||
QString t;
|
||||
if (time) {
|
||||
t = QString::fromAscii((char*)time->data, time->length);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
QString a1time::toSortable() const
|
||||
@ -119,6 +122,11 @@ a1time &a1time::set(const QString &s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void a1time::setUndefined()
|
||||
{
|
||||
ASN1_GENERALIZEDTIME_set_string(time, UNDEFINED_DATE);
|
||||
}
|
||||
|
||||
int a1time::ymdg(int *y, int *m, int *d, int *g) const
|
||||
{
|
||||
int h, M, s;
|
||||
|
||||
@ -25,6 +25,7 @@ class a1time
|
||||
a1time &set(time_t t);
|
||||
a1time &set(const QString &s);
|
||||
a1time &set(int y, int mon, int d, int h, int m, int s);
|
||||
void setUndefined();
|
||||
QString toPretty() const;
|
||||
QString toPlain() const;
|
||||
QString toSortable() const;
|
||||
|
||||
@ -481,8 +481,14 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
|
||||
// Step 3 - Choose the Date
|
||||
// Date handling
|
||||
cert->setNotBefore( dlg->notBefore->getDate() );
|
||||
cert->setNotAfter( dlg->notAfter->getDate() );
|
||||
cert->setNotBefore(dlg->notBefore->getDate());
|
||||
a1time a;
|
||||
if (dlg->noWellDefinedExpDate->isChecked())
|
||||
a.setUndefined();
|
||||
else
|
||||
a = dlg->notAfter->getDate();
|
||||
|
||||
cert->setNotAfter(a);
|
||||
|
||||
if (cert->resetTimes(signcert) > 0) {
|
||||
if (QMessageBox::information(mainwin,tr(XCA_TITLE),
|
||||
|
||||
@ -92,8 +92,10 @@ bool pki_scard::init_p11engine(QString file, bool silent)
|
||||
// XCA_ENGINE_cmd(e, "VERBOSE", NULL);
|
||||
|
||||
ENGINE_init(e);
|
||||
if (ERR_peek_error() != 0)
|
||||
if (ERR_peek_error() != 0) {
|
||||
ign_openssl_error();
|
||||
return false;
|
||||
}
|
||||
p11_engine = e;
|
||||
return true;
|
||||
}
|
||||
|
||||
107
ui/NewX509.ui
107
ui/NewX509.ui
@ -5,20 +5,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>499</width>
|
||||
<height>539</height>
|
||||
<width>547</width>
|
||||
<height>599</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
@ -85,7 +79,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget" >
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_0" >
|
||||
<attribute name="title" >
|
||||
@ -626,9 +620,6 @@ If this list is disabled, you only can create a self-signed certificate.</string
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="genKeyBut" >
|
||||
<property name="toolTip" >
|
||||
<string>This funny button creates a key. Go figure.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Generate a new key</string>
|
||||
</property>
|
||||
@ -643,13 +634,7 @@ If this list is disabled, you only can create a self-signed certificate.</string
|
||||
<attribute name="title" >
|
||||
<string>Extensions</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
@ -811,25 +796,29 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" native="1" name="timewidget" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="validityBox" >
|
||||
<property name="title" >
|
||||
<string>Validity</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="TextLabel1_2_3_2" >
|
||||
<property name="text" >
|
||||
<string>Not before</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="Validity" name="notBefore" >
|
||||
<property name="displayFormat" >
|
||||
@ -843,6 +832,13 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="TextLabel2_4_2" >
|
||||
<property name="text" >
|
||||
<string>Not after</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="Validity" name="notAfter" >
|
||||
<property name="displayFormat" >
|
||||
@ -856,20 +852,6 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="TextLabel1_2_3_2" >
|
||||
<property name="text" >
|
||||
<string>Not before</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="TextLabel2_4_2" >
|
||||
<property name="text" >
|
||||
<string>Not after</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -878,19 +860,9 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
<property name="title" >
|
||||
<string>Time range</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QPushButton" name="applyTime" >
|
||||
<property name="text" >
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout_2" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLineEdit" name="validNumber" />
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="validRange" >
|
||||
@ -911,6 +883,19 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QPushButton" name="applyTime" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QCheckBox" name="midnightCB" >
|
||||
<property name="toolTip" >
|
||||
@ -921,8 +906,12 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLineEdit" name="validNumber" />
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QCheckBox" name="noWellDefinedExpDate" >
|
||||
<property name="text" >
|
||||
<string>No well-defined expiration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@ -507,6 +507,11 @@ void NewX509::newKeyDone(QString name)
|
||||
keyList->setCurrentIndex(keys.indexOf(name));
|
||||
}
|
||||
|
||||
void NewX509::on_noWellDefinedExpDate_toggled(bool)
|
||||
{
|
||||
notAfter->setEnabled(!noWellDefinedExpDate->isChecked());
|
||||
}
|
||||
|
||||
void NewX509::on_usedKeysToo_toggled(bool)
|
||||
{
|
||||
QString cur = keyList->currentText();
|
||||
@ -762,7 +767,7 @@ QString NewX509::mandatoryDnRemain()
|
||||
x509name n;
|
||||
int i;
|
||||
|
||||
if (fromReqCB->isChecked())
|
||||
if (fromReqCB->isChecked() && !reqSubChange->isChecked())
|
||||
n = getSelectedReq()->getSubject();
|
||||
else
|
||||
n = getX509name();
|
||||
@ -849,23 +854,8 @@ void NewX509::on_okButton_clicked()
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (notBefore->getDate().get_utc() == NULL ||
|
||||
notAfter->getDate().get_utc() == NULL) {
|
||||
switch (QMessageBox::warning(this, tr(XCA_TITLE),
|
||||
tr("The validity dates are out of range (1950 - 2049) to create "
|
||||
"valid certificates. If you continue, your client may "
|
||||
"reject the certificate."),
|
||||
tr("Ok"), tr("Abort rollout"), tr("Continue rollout")))
|
||||
{
|
||||
case -1:
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (notBefore->getDate() > notAfter->getDate()) {
|
||||
if (notBefore->getDate() > notAfter->getDate() &&
|
||||
!noWellDefinedExpDate->isChecked()) {
|
||||
switch (QMessageBox::warning(this, tr(XCA_TITLE),
|
||||
tr("The certificate will be out of date before it becomes valid. "
|
||||
"You most probably mixed up both dates."),
|
||||
|
||||
@ -115,6 +115,7 @@ class NewX509: public QDialog, public Ui::NewX509
|
||||
void on_usedKeysToo_toggled(bool checked);
|
||||
void on_tabWidget_currentChanged(int idx);
|
||||
void on_reqSubChange_clicked();
|
||||
void on_noWellDefinedExpDate_toggled(bool);
|
||||
|
||||
signals:
|
||||
void genKey(QString);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user