Remove SPKAC support. Netscape is not of this world anymore.

I discovered some bugs in SPKAC handling and fixing them was hard.
Because of this bugs noone may have used the feature in the past.

Remove it.
This commit is contained in:
Christian Hohnstaedt 2018-02-13 09:27:38 +01:00
parent b0d131e79a
commit eb6382d6aa
10 changed files with 13 additions and 181 deletions

View File

@ -19,7 +19,7 @@ imgres.cpp: imgres.rcc
@$(PRINT) " RCC [$(BASENAME)] $@"
$(RCC) -o $@ $<
imgres.rcc: bigcert.png bigcrl.png bigcsr.png bigkey.png bigtemp.png crl.png halfkey.png invalidcertkey.png invalidcert.png key.png netscape.png reqkey.png req.png spki.png template.png validcertkey.png validcert.png scard.png
imgres.rcc: bigcert.png bigcrl.png bigcsr.png bigkey.png bigtemp.png crl.png halfkey.png invalidcertkey.png invalidcert.png key.png netscape.png reqkey.png req.png template.png validcertkey.png validcert.png scard.png
w32res.o: w32res.rc key.ico xca.ico xdb.ico
@$(PRINT) " WINDRES $@"

View File

@ -16,7 +16,6 @@
<file>netscape.png</file>
<file>reqkey.png</file>
<file>req.png</file>
<file>spki.png</file>
<file>template.png</file>
<file>validcertkey.png</file>
<file>validcert.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -28,6 +28,7 @@ pki_base *load_base::loadItem(QString s)
return NULL;
try {
pki->fload(s);
openssl_error();
}
catch (errorEx &err){
delete pki;
@ -64,8 +65,7 @@ pki_base * load_key::newItem()
load_req::load_req()
:load_base()
{
filter = QObject::tr("PKCS#10 CSR ( *.pem *.der *.csr );; "
"Netscape Request ( *.spkac *.spc );;") + filter;
filter = QObject::tr("PKCS#10 CSR ( *.pem *.der *.csr );; ") + filter;
caption = QObject::tr("Import Request");
}

View File

@ -18,7 +18,7 @@
#include "openssl_compat.h"
QPixmap *pki_x509req::icon[4] = { NULL, NULL, NULL, NULL };
QPixmap *pki_x509req::icon[3] = { NULL, NULL, NULL };
pki_x509req::pki_x509req(const QString name)
: pki_x509super(name)
@ -27,7 +27,6 @@ pki_x509req::pki_x509req(const QString name)
class_name = "pki_x509req";
request = X509_REQ_new();
pki_openssl_error();
spki = NULL;
dataVersion=1;
pkiType=x509_req;
done = false;
@ -37,9 +36,6 @@ pki_x509req::~pki_x509req()
{
if (request)
X509_REQ_free(request);
if (spki)
NETSCAPE_SPKI_free(spki);
pki_openssl_error();
}
void pki_x509req::createReq(pki_key *key, const x509name &dn, const EVP_MD *md, extList el)
@ -89,7 +85,7 @@ QString pki_x509req::getMsg(msg_type msg)
* %2 will be replaced by the internal name of the request
*/
QString type = isSpki() ? "SPKAC" : "PKCS#10";
QString type = "PKCS#10";
switch (msg) {
case msg_import: return tr("Successfully imported the %1 certificate request '%2'").arg(type);
@ -127,11 +123,6 @@ void pki_x509req::fload(const QString fname)
_req = d2i_X509_REQ_fp(fp, NULL);
}
fclose(fp);
// SPKAC
if (!_req) {
pki_ign_openssl_error();
ret = load_spkac(fname);
}
if (ret || pki_ign_openssl_error()) {
if (_req)
X509_REQ_free(_req);
@ -161,26 +152,11 @@ void pki_x509req::d2i(QByteArray &ba)
}
}
void pki_x509req::d2i_spki(QByteArray &ba)
{
NETSCAPE_SPKI *s = (NETSCAPE_SPKI*)d2i_bytearray(
D2I_VOID(d2i_NETSCAPE_SPKI), ba);
if (s) {
NETSCAPE_SPKI_free(spki);
spki = s;
}
}
QByteArray pki_x509req::i2d()
{
return i2d_bytearray(I2D_VOID(i2d_X509_REQ), request);
}
QByteArray pki_x509req::i2d_spki()
{
return i2d_bytearray(I2D_VOID(i2d_NETSCAPE_SPKI), spki);
}
void pki_x509req::fromData(const unsigned char *p, db_header_t *head )
{
int size;
@ -210,15 +186,6 @@ x509name pki_x509req::getSubject() const
int pki_x509req::sigAlg()
{
if (spki) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
ASN1_OBJECT *o = NULL;
X509_PUBKEY_get0_param(&o, 0, 0, 0, spki->spkac->pubkey);
return OBJ_obj2nid(o);
#else
return OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm);
#endif
}
return X509_REQ_get_signature_nid(request);
}
@ -227,22 +194,13 @@ void pki_x509req::setSubject(const x509name &n)
X509_REQ_set_subject_name(request, n.get());
}
bool pki_x509req::isSpki() const
{
return spki != NULL;
}
QByteArray pki_x509req::toData()
{
QByteArray ba;
ba += i2d();
if (spki) {
ba += i2d_spki();
}
QByteArray ba = i2d();
pki_openssl_error();
return ba;
}
void pki_x509req::writeDefault(const QString fname)
{
writeReq(fname + QDir::separator() + getIntName() + ".csr", true);
@ -276,13 +234,7 @@ BIO *pki_x509req::pem(BIO *b, int format)
int pki_x509req::verify()
{
EVP_PKEY *pkey = X509_REQ_get_pubkey(request);
bool x;
if (spki) {
x = NETSCAPE_SPKI_verify(spki, pkey) > 0;
} else {
x = X509_REQ_verify(request,pkey) > 0;
}
bool x = X509_REQ_verify(request,pkey) > 0;
pki_ign_openssl_error();
EVP_PKEY_free(pkey);
return x;
@ -309,85 +261,6 @@ extList pki_x509req::getV3ext()
return el;
}
/*!
Load a spkac FILE into this request structure.
The file format follows the conventions understood by the 'openssl ca'
command. (see: 'man ca')
*/
int pki_x509req::load_spkac(const QString filename)
{
QFile file;
x509name subject;
EVP_PKEY *pktmp = NULL;
pki_ign_openssl_error();
file.setFileName(filename);
if (!file.open(QIODevice::ReadOnly))
return 1;
while (!file.atEnd()) {
int idx, nid;
QByteArray line = file.readLine();
if (line.size() == 0)
continue;
idx = line.indexOf('=');
if (idx == -1)
goto err;
QString type = line.left(idx).trimmed();
line = line.mid(idx+1).trimmed();
idx = type.lastIndexOf(QRegExp("[:,\\.]"));
if (idx != -1)
type = type.mid(idx+1);
if ((nid = OBJ_txt2nid(CCHAR(type))) == NID_undef) {
if (type != "SPKAC")
goto err;
pki_ign_openssl_error();
spki = NETSCAPE_SPKI_b64_decode(line, line.size());
if (!spki)
goto err;
/*
Now extract the key from the SPKI structure and
check the signature.
*/
pktmp = NETSCAPE_SPKI_get_pubkey(spki);
if (pktmp == NULL)
goto err;
if (NETSCAPE_SPKI_verify(spki, pktmp) != 1)
goto err;
} else {
// gather all values in the x509name subject.
subject.addEntryByNid(nid,
filename2QString(line.constData()));
}
}
if (!pktmp)
goto err;
setSubject(subject);
X509_REQ_set_pubkey(request, pktmp);
EVP_PKEY_free(pktmp);
return 0;
err:
if (pktmp)
EVP_PKEY_free(pktmp);
if (spki) {
NETSCAPE_SPKI_free(spki);
spki = NULL;
}
return 1;
}
ASN1_IA5STRING *pki_x509req::spki_challange()
{
if (spki) {
if (spki->spkac->challenge->length >0)
return spki->spkac->challenge;
}
return NULL;
}
QString pki_x509req::getAttribute(int nid)
{
int n;
@ -431,12 +304,10 @@ QVariant pki_x509req::getIcon(dbheader *hd)
k = getRefKey();
if (k && k->isPrivKey())
pixnum = 1;
if (spki != NULL)
pixnum = 2;
break;
case HD_req_signed:
if (done)
pixnum = 3;
pixnum = 2;
break;
}
if (pixnum == -1)
@ -461,11 +332,4 @@ void pki_x509req::oldFromData(unsigned char *p, int size)
privkey = NULL;
d2i(ba);
if (ba.count() > 0)
d2i_spki(ba);
if (ba.count() > 0) {
my_error(tr("Wrong Size %1").arg(ba.count()));
}
}

View File

@ -21,21 +21,15 @@ class pki_x509;
class pki_x509req : public pki_x509super
{
Q_OBJECT
private:
//loading spkac file and convert it to a request
int load_spkac(const QString filename);
//for checking spkac content-fields
int fix_data(int nid, int *type);
protected:
X509_REQ *request;
NETSCAPE_SPKI *spki;
bool done;
int sigAlg();
public:
extList getV3ext();
static QPixmap *icon[4];
static QPixmap *icon[3];
pki_x509req(QString name = "");
void fromPEM_BIO(BIO *bio, QString name);
void fload(const QString fname);
@ -45,7 +39,6 @@ class pki_x509req : public pki_x509super
void oldFromData(unsigned char *p, int size);
QByteArray toData();
x509name getSubject() const;
bool isSpki() const;
void writeReq(const QString fname, bool pem);
X509_REQ *getReq()
{
@ -60,7 +53,6 @@ class pki_x509req : public pki_x509super
extList el);
void setSubject(const x509name &n);
/* SPKAC special functions */
ASN1_IA5STRING *spki_challange();
QVariant column_data(dbheader *hd);
QVariant getIcon(dbheader *hd);
void setDone(bool d = true)
@ -73,9 +65,7 @@ class pki_x509req : public pki_x509super
}
virtual QString getMsg(msg_type msg);
void d2i(QByteArray &ba);
void d2i_spki(QByteArray &ba);
QByteArray i2d();
QByteArray i2d_spki();
BIO *pem(BIO *, int);
bool visible();
};

View File

@ -52,10 +52,6 @@ class pki_x509super : public pki_x509name
};
virtual QString getSigAlg();
virtual const EVP_MD *getDigest();
virtual bool isSpki() const
{
return false;
}
pki_key *getRefKey() const;
void setRefKey(pki_key *ref);
void delRefKey(pki_key *ref);

View File

@ -167,11 +167,7 @@ void CertDetail::setReq(pki_x509req *req)
signature->setText("Failed");
} else {
signature->setGreen();
if (req->isSpki()) {
signature->setText("SPKAC");
} else {
signature->setText("PKCS#10");
}
signature->setText("PKCS#10");
}
signature->disableToolTip();
trustState->hide();
@ -222,16 +218,6 @@ void CertDetail::setReq(pki_x509req *req)
}
ii++;
}
ASN1_IA5STRING *chal = req->spki_challange();
if (chal) {
QLabel *label;
label = new QLabel(this);
label->setText(QString("SPKI Challenge String"));
attrLayout->addWidget(label, 0, 0);
label = labelFromAsn1String(chal);
attrLayout->addWidget(label, 0, 1);
added++;
}
if (!added) {
tabwidget->removeTab(2);
}

View File

@ -256,8 +256,7 @@ void MainWindow::init_images()
pki_scard::icon[0] = loadImg("scard.png");
pki_x509req::icon[0] = loadImg("req.png");
pki_x509req::icon[1] = loadImg("reqkey.png");
pki_x509req::icon[2] = loadImg("spki.png");
pki_x509req::icon[3] = doneIco;
pki_x509req::icon[2] = doneIco;
pki_x509::icon[0] = loadImg("validcert.png");
pki_x509::icon[1] = loadImg("validcertkey.png");
pki_x509::icon[2] = loadImg("invalidcert.png");

View File

@ -23,10 +23,8 @@ void X509SuperTreeView::fillContextMenu(QMenu *menu, QMenu *subExport,
return;
subExport->addAction(tr("OpenSSL config"), this, SLOT(toOpenssl()));
subExport->setEnabled(!x->isSpki());
transform = menu->addMenu(tr("Transform"));
transform->addAction(tr("Template"), this,
SLOT(toTemplate()))->setEnabled(!x->isSpki());
transform->addAction(tr("Template"), this, SLOT(toTemplate()));
transform->addAction(tr("Public key"), this,
SLOT(extractPubkey()))->setEnabled(!x->getRefKey());
}