mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Nullpointer-crash eliminated
This commit is contained in:
parent
cb00e4efc4
commit
9be85c8eeb
21
KeyDetail.ui
21
KeyDetail.ui
@ -11,8 +11,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>558</width>
|
||||
<height>387</height>
|
||||
<width>600</width>
|
||||
<height>447</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
@ -557,14 +557,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QMultiLineEdit</class>
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>keyModulus</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>wrapPolicy</name>
|
||||
<enum>Anywhere</enum>
|
||||
<name>frameShape</name>
|
||||
<enum>Panel</enum>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>frameShadow</name>
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>alignment</name>
|
||||
<set>WordBreak|AlignVCenter|AlignLeft</set>
|
||||
</property>
|
||||
<property>
|
||||
<name>wordwrap</name>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
|
||||
@ -155,18 +155,22 @@ bool MainWindow::showDetailsKey(pki_key *key, bool import)
|
||||
delete detDlg;
|
||||
return false;
|
||||
}
|
||||
string ndesc = detDlg->keyDesc->text().latin1();
|
||||
bool ret = detDlg->exec();
|
||||
string ndesc = detDlg->keyDesc->text().latin1();
|
||||
delete detDlg;
|
||||
CERR(ndesc << " " << key->getDescription());
|
||||
if ( ret && ndesc != key->getDescription()) {
|
||||
MARK
|
||||
try {
|
||||
keys->renamePKI(key, ndesc);
|
||||
MARK
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
Error(err);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MARK
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -111,8 +111,8 @@ void db_key::inToCont(pki_base *pki)
|
||||
void db_key::updateViewPKI(pki_base *pki)
|
||||
{
|
||||
CERR("updateViewPKI()");
|
||||
db_base::updateViewPKI(pki);
|
||||
if (! pki) return;
|
||||
db_base::updateViewPKI(pki);
|
||||
int pixnum = 0;
|
||||
QListViewItem *current = (QListViewItem *)pki->getPointer();
|
||||
if (!current) return;
|
||||
|
||||
@ -57,6 +57,7 @@ pki_base::pki_base(const string d)
|
||||
error = "";
|
||||
desc = d;
|
||||
className = "pki_base";
|
||||
pointer=NULL;
|
||||
}
|
||||
|
||||
pki_base::pki_base()
|
||||
@ -64,6 +65,7 @@ pki_base::pki_base()
|
||||
error = "";
|
||||
desc = "";
|
||||
className = "pki_base";
|
||||
pointer=NULL;
|
||||
}
|
||||
|
||||
pki_base::~pki_base(void)
|
||||
|
||||
@ -67,10 +67,10 @@ class pki_base
|
||||
string desc;
|
||||
string error;
|
||||
string className;
|
||||
void *pointer;
|
||||
void openssl_error(const string myerr = "");
|
||||
void fopen_error(const string fname);
|
||||
bool ign_openssl_error();
|
||||
void *pointer;
|
||||
int intToData(unsigned char **p, const int val);
|
||||
int intFromData(unsigned char **p);
|
||||
int boolToData(unsigned char **p, const bool val);
|
||||
|
||||
@ -53,9 +53,17 @@
|
||||
|
||||
char pki_key::passwd[40]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
void pki_key::init()
|
||||
{
|
||||
ucount = 0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
pki_key::pki_key(const string d, void (*cb)(int, int,void *),void *prog, int bits = 1024, int type): pki_base(d)
|
||||
{
|
||||
init();
|
||||
key = EVP_PKEY_new();
|
||||
openssl_error();
|
||||
key->type = type;
|
||||
if (type == EVP_PKEY_RSA) {
|
||||
RSA *rsakey;
|
||||
@ -63,45 +71,42 @@ pki_key::pki_key(const string d, void (*cb)(int, int,void *),void *prog, int bit
|
||||
if (rsakey) EVP_PKEY_set1_RSA(key, rsakey);
|
||||
}
|
||||
openssl_error();
|
||||
ucount=0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
pki_key::pki_key(const pki_key *pk)
|
||||
:pki_base(pk->desc)
|
||||
{
|
||||
init();
|
||||
key = EVP_PKEY_new();
|
||||
openssl_error();
|
||||
key->type = pk->key->type;
|
||||
if (key->type == EVP_PKEY_RSA) {
|
||||
key->pkey.rsa=((RSA *)ASN1_dup( (int (*)())i2d_RSAPrivateKey, (char *(*)())d2i_RSAPrivateKey,(char *)pk->key->pkey.rsa));
|
||||
}
|
||||
// TODO add DSA support.....
|
||||
openssl_error();
|
||||
ucount=0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
pki_key::pki_key(const string d, int type )
|
||||
:pki_base(d)
|
||||
{
|
||||
init();
|
||||
key = EVP_PKEY_new();
|
||||
key->type = type;
|
||||
openssl_error();
|
||||
ucount=0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
pki_key::pki_key(EVP_PKEY *pkey)
|
||||
:pki_base("")
|
||||
{
|
||||
init();
|
||||
key = pkey;
|
||||
ucount=0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
pki_key::pki_key(const string fname, pem_password_cb *cb, int type )
|
||||
:pki_base(fname)
|
||||
{
|
||||
init();
|
||||
PASS_INFO p;
|
||||
string title = XCA_TITLE;
|
||||
string description = "Please enter the password to decrypt the RSA key.";
|
||||
@ -158,8 +163,6 @@ pki_key::pki_key(const string fname, pem_password_cb *cb, int type )
|
||||
else fopen_error(fname);
|
||||
CERR("end of loading");
|
||||
fclose(fp);
|
||||
ucount=0;
|
||||
className = "pki_key";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -105,6 +105,7 @@ class pki_key: public pki_base
|
||||
|
||||
pki_key(const string d, int type=EVP_PKEY_RSA);
|
||||
pki_key(EVP_PKEY *pkey);
|
||||
void init();
|
||||
void fromData(unsigned char *p, int size);
|
||||
unsigned char *toData(int *size);
|
||||
bool compare(pki_base *ref);
|
||||
|
||||
@ -100,9 +100,9 @@ pki_x509::pki_x509(string d,pki_key *clientKey, pki_x509req *req, pki_x509 *sign
|
||||
|
||||
pki_x509::pki_x509(X509 *c) : pki_base()
|
||||
{
|
||||
init();
|
||||
cert = c;
|
||||
openssl_error();
|
||||
init();
|
||||
}
|
||||
|
||||
pki_x509::pki_x509(const pki_x509 *crt)
|
||||
@ -134,7 +134,6 @@ pki_x509::pki_x509(const string fname)
|
||||
{
|
||||
FILE *fp = fopen(fname.c_str(),"r");
|
||||
init();
|
||||
cert = NULL;
|
||||
if (fp != NULL) {
|
||||
cert = PEM_read_X509(fp, NULL, NULL, NULL);
|
||||
if (!cert) {
|
||||
@ -186,6 +185,7 @@ void pki_x509::init()
|
||||
crlDays = 30;
|
||||
lastCrl = NULL;
|
||||
className="pki_x509";
|
||||
cert=NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ bool pki_x509::canSign()
|
||||
if (pkey->isPubKey()) return false;
|
||||
bc = (BASIC_CONSTRAINTS *)X509_get_ext_d2i(cert, NID_basic_constraints, &crit, NULL);
|
||||
openssl_error();
|
||||
if (!bc) return false;
|
||||
if (!bc) return true;
|
||||
if (!bc->ca) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,6 +52,13 @@
|
||||
|
||||
#include "pki_x509req.h"
|
||||
|
||||
void pki_x509req::init()
|
||||
{
|
||||
request = NULL;
|
||||
privkey = NULL;
|
||||
className = "pki_x509req";
|
||||
}
|
||||
|
||||
|
||||
pki_x509req::pki_x509req(pki_key *key, const string cn,
|
||||
const string c, const string l,
|
||||
@ -60,6 +67,7 @@ pki_x509req::pki_x509req(pki_key *key, const string cn,
|
||||
const string d, const string challenge)
|
||||
:pki_base( d )
|
||||
{
|
||||
init();
|
||||
request = X509_REQ_new();
|
||||
openssl_error();
|
||||
if (key == NULL) {
|
||||
@ -100,23 +108,22 @@ pki_x509req::pki_x509req(pki_key *key, const string cn,
|
||||
openssl_error();
|
||||
privkey = key;
|
||||
key->incUcount();
|
||||
className="pki_x509req";
|
||||
}
|
||||
|
||||
|
||||
|
||||
pki_x509req::pki_x509req() : pki_base()
|
||||
{
|
||||
init();
|
||||
request = X509_REQ_new();
|
||||
openssl_error();
|
||||
privkey = NULL;
|
||||
className="pki_x509req";
|
||||
}
|
||||
|
||||
|
||||
pki_x509req::~pki_x509req()
|
||||
{
|
||||
X509_REQ_free(request);
|
||||
if (request)
|
||||
X509_REQ_free(request);
|
||||
openssl_error();
|
||||
if (privkey)
|
||||
privkey->decUcount();
|
||||
@ -125,7 +132,7 @@ pki_x509req::~pki_x509req()
|
||||
|
||||
pki_x509req::pki_x509req(const string fname)
|
||||
{
|
||||
request = NULL;
|
||||
init();
|
||||
FILE *fp = fopen(fname.c_str(),"r");
|
||||
if (fp != NULL) {
|
||||
request = PEM_read_X509_REQ(fp, NULL, NULL, NULL);
|
||||
@ -148,8 +155,6 @@ pki_x509req::pki_x509req(const string fname)
|
||||
}
|
||||
else fopen_error(fname);
|
||||
fclose(fp);
|
||||
privkey = NULL;
|
||||
className="pki_x509req";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ class pki_x509req : public pki_base
|
||||
pki_x509req();
|
||||
pki_x509req(const string fname);
|
||||
~pki_x509req();
|
||||
void init();
|
||||
virtual void fromData(unsigned char *p, int size);
|
||||
virtual unsigned char *toData(int *size);
|
||||
virtual bool compare(pki_base *refreq);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user