mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
SF Feat. Req. #80 Create new certificate, based on existing certificate
This commit is contained in:
parent
7029db8847
commit
595300617f
@ -436,6 +436,18 @@ void db_x509::newCert(pki_temp *temp)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void db_x509::newCert(pki_x509 *cert)
|
||||
{
|
||||
NewX509 *dlg = new NewX509(mainwin);
|
||||
emit connNewX509(dlg);
|
||||
dlg->setCert();
|
||||
dlg->defineCert(cert);
|
||||
if (dlg->exec()) {
|
||||
newCert(dlg);
|
||||
}
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void db_x509::newCert(NewX509 *dlg)
|
||||
{
|
||||
pki_x509 *cert = NULL;
|
||||
@ -647,6 +659,8 @@ void db_x509::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
|
||||
transform->addAction(tr("Request"),
|
||||
this, SLOT(toRequest()))->
|
||||
setEnabled(privkey && privkey->isPrivKey());
|
||||
transform->addAction(tr("Similar Certificate"),
|
||||
this, SLOT(toCertificate()));
|
||||
transform->addAction(tr("Template"), this, SLOT(toTemplate()));
|
||||
|
||||
menu->addAction(tr("Delete"), this, SLOT(delete_ask()));
|
||||
@ -1081,6 +1095,15 @@ void db_x509::genCrl()
|
||||
mainwin->crls->newItem(cert);
|
||||
}
|
||||
|
||||
void db_x509::toCertificate()
|
||||
{
|
||||
pki_x509 *cert = static_cast<pki_x509*>(currentIdx.internalPointer());
|
||||
if (!cert)
|
||||
return;
|
||||
if (!cert->getRefKey())
|
||||
extractPubkey();
|
||||
newCert(cert);
|
||||
}
|
||||
|
||||
void db_x509::toRequest()
|
||||
{
|
||||
|
||||
@ -47,6 +47,7 @@ class db_x509: public db_x509super
|
||||
pki_x509 *getBySubject(const x509name &xname, pki_x509 *last = NULL);
|
||||
pki_base *insert(pki_base *item);
|
||||
void newCert(NewX509 *dlg);
|
||||
void newCert(pki_x509 *cert);
|
||||
void writePKCS12(pki_x509 *cert, QString s, bool chain);
|
||||
void writePKCS7(pki_x509 *cert, QString s, int type);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
@ -70,6 +71,7 @@ class db_x509: public db_x509super
|
||||
void genCrl();
|
||||
void caProperties();
|
||||
void toRequest();
|
||||
void toCertificate();
|
||||
void toToken();
|
||||
void toOtherToken();
|
||||
void newCert(pki_temp *);
|
||||
|
||||
@ -368,6 +368,33 @@ void NewX509::defineRequest(pki_x509req *req)
|
||||
on_fromReqCB_clicked();
|
||||
}
|
||||
|
||||
void NewX509::defineCert(pki_x509 *cert)
|
||||
{
|
||||
pki_temp *temp = new pki_temp("");
|
||||
temp->fromCert(cert);
|
||||
description->setText(cert->getIntName());
|
||||
pki_x509 *signer = cert->getSigner();
|
||||
if (signer == cert) {
|
||||
foreignSignRB->setChecked(false);
|
||||
} else if (signer) {
|
||||
defineSigner(signer);
|
||||
}
|
||||
defineTemplate(temp);
|
||||
delete temp;
|
||||
|
||||
pki_key *key = cert->getRefKey();
|
||||
if (key) {
|
||||
usedKeysToo->setChecked(true);
|
||||
keyList->setCurrentIndex(private_keys.indexOf(
|
||||
key->getIntNameWithType()));
|
||||
}
|
||||
|
||||
notBefore->setDate(cert->getNotBefore());
|
||||
notAfter->setDate(cert->getNotAfter());
|
||||
|
||||
hashAlgo->setCurrentMD(cert->getDigest());
|
||||
}
|
||||
|
||||
void NewX509::defineSigner(pki_x509 *defcert)
|
||||
{
|
||||
int index;
|
||||
|
||||
@ -74,6 +74,7 @@ class NewX509: public QDialog, public Ui::NewX509
|
||||
void toTemplate(pki_temp *temp);
|
||||
void fromTemplate(pki_temp *temp);
|
||||
void defineTemplate(pki_temp *temp);
|
||||
void defineCert(pki_x509 *cert);
|
||||
void defineRequest(pki_x509req *req);
|
||||
void defineSigner(pki_x509 *defcert);
|
||||
void templateChanged(pki_temp *templ);
|
||||
|
||||
@ -73,6 +73,24 @@ void hashBox::setCurrentString(QString md)
|
||||
}
|
||||
}
|
||||
|
||||
void hashBox::setCurrentMD(const EVP_MD *md)
|
||||
{
|
||||
int hash_nid;
|
||||
unsigned idx;
|
||||
|
||||
if (!md)
|
||||
return;
|
||||
|
||||
if (!OBJ_find_sigid_algs(EVP_MD_type(md), &hash_nid, NULL))
|
||||
hash_nid = EVP_MD_type(md);
|
||||
for (idx = 0; idx<ARRAY_SIZE(hashalgos); idx++) {
|
||||
if (hash_nid == EVP_MD_type(hashalgos[idx].md)) {
|
||||
setCurrentString(hashalgos[idx].name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hashBox::setupHashes(QList<int> nids)
|
||||
{
|
||||
QString md = currentText();
|
||||
|
||||
@ -24,6 +24,7 @@ class hashBox: public QComboBox
|
||||
void setKeyType(int type);
|
||||
const EVP_MD *currentHash();
|
||||
QString currentHashName();
|
||||
void setCurrentMD(const EVP_MD *md);
|
||||
void setCurrentAsDefault();
|
||||
void setDefaultHash();
|
||||
void setupHashes(QList<int> nids);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user