Version++

added $id$
pkcs12 import implemented
This commit is contained in:
chris 2002-09-08 21:37:44 +00:00
parent 463e3efc95
commit e1b31985ea
36 changed files with 177 additions and 43 deletions

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<width>534</width>
<height>763</height>
</rect>
</property>
@ -1800,7 +1800,7 @@
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton10</cstring>
<cstring>but_ok</cstring>
</property>
<property stdset="1">
<name>text</name>
@ -1832,7 +1832,7 @@
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton11</cstring>
<cstring>but_cancel</cstring>
</property>
<property stdset="1">
<name>text</name>
@ -1845,13 +1845,13 @@
</widget>
<connections>
<connection>
<sender>PushButton10</sender>
<sender>but_ok</sender>
<signal>clicked()</signal>
<receiver>CertDetail_UI</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>PushButton11</sender>
<sender>but_cancel</sender>
<signal>clicked()</signal>
<receiver>CertDetail_UI</receiver>
<slot>reject()</slot>

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>470</width>
<width>466</width>
<height>349</height>
</rect>
</property>
@ -766,7 +766,7 @@
</property>
<property stdset="1">
<name>textFormat</name>
<enum>PlainText</enum>
<enum>AutoText</enum>
</property>
</widget>
<widget>
@ -788,7 +788,7 @@
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton1</cstring>
<cstring>but_ok</cstring>
</property>
<property stdset="1">
<name>text</name>
@ -824,7 +824,7 @@
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton2</cstring>
<cstring>but_cancel</cstring>
</property>
<property stdset="1">
<name>text</name>
@ -837,19 +837,19 @@
</widget>
<connections>
<connection>
<sender>PushButton2</sender>
<sender>but_cancel</sender>
<signal>clicked()</signal>
<receiver>KeyDetail_UI</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>PushButton1</sender>
<sender>but_ok</sender>
<signal>clicked()</signal>
<receiver>KeyDetail_UI</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>PushButton1</sender>
<sender>but_ok</sender>
<signal>clicked()</signal>
<receiver>KeyDetail_UI</receiver>
<slot>accept()</slot>

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -117,9 +118,9 @@ class MainWindow: public MainWindow_UI
void loadSettings();
void saveSettings();
void initPass();
void showDetailsKey(pki_key *key);
bool showDetailsKey(pki_key *key, bool import = false);
void showDetailsReq(pki_x509req *req);
void showDetailsCert(pki_x509 *cert);
bool showDetailsCert(pki_x509 *cert, bool import = false);
static int passRead(char *buf, int size, int rwflag, void *userdata);
static int passWrite(char *buf, int size, int rwflag, void *userdata);
static void incProgress(int a, int b, void *progress);

View File

@ -12,7 +12,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>820</width>
<width>816</width>
<height>604</height>
</rect>
</property>
@ -534,6 +534,17 @@
<string>Export PKCS#12</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton18</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Import PKCS#12</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
@ -784,6 +795,12 @@
<receiver>MainWindow_UI</receiver>
<slot>showPopupReq(QListViewItem *, const QPoint &amp;, int)</slot>
</connection>
<connection>
<sender>PushButton18</sender>
<signal>clicked()</signal>
<receiver>MainWindow_UI</receiver>
<slot>loadPKCS12()</slot>
</connection>
<slot access="public">deleteCert()</slot>
<slot access="public">deleteKey()</slot>
<slot access="public">deleteReq()</slot>
@ -793,7 +810,7 @@
<slot access="public">newCert()</slot>
<slot access="public">newKey()</slot>
<slot access="public">newReq()</slot>
<slot access="public">showPopupKey(QListViewItem *, const QPoint &amp;, int)</slot>
<slot access="public">loadPKCS12()</slot>
<slot access="public">showDetailsCert()</slot>
<slot access="public">showDetailsCert(QListViewItem *)</slot>
<slot access="public">showDetailsKey()</slot>
@ -801,6 +818,7 @@
<slot access="public">showDetailsReq()</slot>
<slot access="public">showDetailsReq(QListViewItem *)</slot>
<slot access="public">showPopupCert(QListViewItem *, const QPoint &amp;, int)</slot>
<slot access="public">showPopupKey(QListViewItem *, const QPoint &amp;, int)</slot>
<slot access="public">showPopupReq(QListViewItem *, const QPoint &amp;, int)</slot>
<slot access="public">writeCert()</slot>
<slot access="public">writeKey()</slot>

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -109,9 +110,10 @@ void MainWindow::deleteKey()
}
void MainWindow::showDetailsKey(pki_key *key)
bool MainWindow::showDetailsKey(pki_key *key, bool import = false)
{
if (key == NULL ) return;
if (!key) return false;
if (opensslError(key)) return false;
KeyDetail_UI *detDlg = new KeyDetail_UI(this, 0, true, 0 );
detDlg->keyDesc->setText(
@ -127,12 +129,17 @@ void MainWindow::showDetailsKey(pki_key *key)
detDlg->keyPrivEx->setDisabled(true);
}
detDlg->image->setPixmap(*keyImg);
if ( !detDlg->exec()) return;
if (import) {
detDlg->but_ok->setText(tr("Import"));
detDlg->but_cancel->setText(tr("Discard"));
}
if ( !detDlg->exec()) return false;
string ndesc = detDlg->keyDesc->text().latin1();
if (ndesc != key->getDescription()) {
keys->renamePKI(key, ndesc);
}
return true;
}

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -227,10 +228,10 @@ void MainWindow::showDetailsCert(QListViewItem *item)
}
void MainWindow::showDetailsCert(pki_x509 *cert)
bool MainWindow::showDetailsCert(pki_x509 *cert, bool import = false)
{
if (!cert) return;
if (opensslError(cert)) return;
if (!cert) return false;
if (opensslError(cert)) return false;
CertDetail_UI *dlg = new CertDetail_UI(this,0,true);
dlg->image->setPixmap(*certImg);
dlg->descr->setText(cert->getDescription().c_str());
@ -315,14 +316,22 @@ void MainWindow::showDetailsCert(pki_x509 *cert)
// V3 extensions
dlg->v3Extensions->setText(cert->printV3ext().c_str());
// rename the buttons in case of import
if (import) {
dlg->but_ok->setText(tr("Import"));
dlg->but_cancel->setText(tr("Discard"));
}
// show it to the user...
if ( !dlg->exec()) return;
if ( !dlg->exec()) return false;
string ndesc = dlg->descr->text().latin1();
if (ndesc != cert->getDescription()) {
certs->renamePKI(cert, ndesc);
}
opensslError(cert);
if (opensslError(cert)) return false;
return true;
}
void MainWindow::deleteCert()
@ -360,11 +369,56 @@ void MainWindow::loadCert()
void MainWindow::loadPKCS12()
{
pki_pkcs12 *pk12;
pki_x509 *acert;
pki_key *akey;
QStringList filt;
filt.append(tr("PKCS#12 Certificates ( *.p12 )"));
filt.append(tr("All files ( *.* )"));
string s;
QFileDialog *dlg = new QFileDialog(this,0,true);
dlg->setCaption(tr("Certificate import"));
dlg->setFilters(filt);
if (dlg->exec())
s = dlg->selectedFile().latin1();
if (s == "") return;
pk12 = new pki_pkcs12(s, &MainWindow::passRead);
opensslError(pk12);
akey = pk12->getKey();
acert = pk12->getCert();
opensslError(akey);
opensslError(acert);
opensslError(pk12);
insertKey(akey);
insertCert(acert);
for (int i=0; i<pk12->numCa(); i++) {
acert = pk12->getCa(i);
insertCert(acert);
}
/* insert with asking.....
if (showDetailsKey(akey, true)) {
insertKey(akey);
}
else {
delete(akey);
}
if (showDetailsCert(acert,true)) {
insertCert(acert);
}
else {
delete(acert);
}
for (int i=0; i<pk12->numCa(); i++) {
acert = pk12->getCa(i);
if (showDetailsCert(acert, true)) {
insertCert(acert);
}
else {
delete(acert);
}
}
*/
}
void MainWindow::insertCert(pki_x509 *cert)
@ -411,6 +465,7 @@ void MainWindow::writePKCS12()
QFileDialog *dlg = new QFileDialog(this,0,true);
dlg->setCaption(tr("PKCS#12 export"));
dlg->setFilters(filt);
dlg->setMode( QFileDialog::AnyFile );
if (dlg->exec())
s = dlg->selectedFile().latin1();
if (s == "") return;

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -1,13 +1,15 @@
#
# @configure_input@
#
# $id$
#
VERSION=@PACKAGE_VERSION@
TAG=$(shell echo "V.$(VERSION)" |sed "s/\./_/g" )
TARGET=xca-$(VERSION)
GCC=@CXX@
CPPFLAGS=@CPPFLAGS@ -Wall -g
CPPFLAGS=@CPPFLAGS@ -Wall -ggdb
LIBS=-Llib @LDFLAGS@ @LIBS@ -lxcadb -lpki
MOC=@MOC@
@ -70,6 +72,7 @@ clean:
rm -rf *_MOC.cpp *_UI.h *_UI.cpp *~ *.o xca
distclean: clean
make -C lib distclean
rm -f Makefile config.cache config.h
dist:

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

5
README
View File

@ -33,7 +33,8 @@ Installation
============
should be straight forward:
just type 'make' to compile
just type 'configure' to configure the package,
then type 'make' to compile
and as root: 'make install'
for installation
@ -42,10 +43,10 @@ than the recommended software packages, or on an other platform
than Linux, or if it failed :-)
----------------------------------------------------------
if there are any questions regarding this software,
dont hesitate to contact me:
christian@hohnstaedt.de
$id$

View File

@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(xca, 0.2.3)
AC_INIT(xca, 0.2.4)
AC_CONFIG_SRCDIR([MainWindow.h])
AC_CONFIG_HEADERS([config.h])

View File

@ -1,6 +1,7 @@
#
# @configure_input@
#
# $id$
VERSION=@PACKAGE_VERSION@
TARGET=xca-$(VERSION)
@ -34,5 +35,5 @@ clean:
rm -rf *~ *.o *.a
distclean: clean
Makefile
rm -f Makefile

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -68,7 +69,11 @@ pki_key::pki_key(const pki_key *pk)
:pki_base(pk->desc)
{
key = EVP_PKEY_new();
EVP_PKEY_copy_parameters(key, pk->key);
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();
}

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -54,8 +55,8 @@
pki_pkcs12::pki_pkcs12(const string d, pki_x509 *acert, pki_key *akey, pem_password_cb *cb):
pki_base(d)
{
key = akey;
cert = acert;
key = new pki_key(akey);
cert = new pki_x509(acert);
certstack = sk_X509_new_null();
pkcs12 = NULL;
passcb = cb;
@ -69,6 +70,9 @@ pki_pkcs12::pki_pkcs12(const string fname, pem_password_cb *cb)
char pass[30];
EVP_PKEY *mykey;
X509 *mycert;
key=NULL; cert=NULL; pkcs12=NULL;
passcb = cb;
certstack = sk_X509_new_null();
PASS_INFO p;
string title = "Password to import the PKCS#12 certificate";
string description = "Please enter the password to encrypt the PKCS#12 bag.";
@ -77,14 +81,24 @@ pki_pkcs12::pki_pkcs12(const string fname, pem_password_cb *cb)
fp = fopen(fname.c_str(), "rb");
if (fp) {
pkcs12 = d2i_PKCS12_fp(fp, NULL);
CERR<<"PK12 A" <<endl;
fclose(fp);
if (openssl_error()) return;
passcb(pass, 30, 0, &p);
CERR<<"PK12 B" <<endl;
PKCS12_parse(pkcs12, pass, &mykey, &mycert, &certstack);
CERR<<"PK12 C" <<endl;
if (openssl_error()) return;
key = new pki_key(mykey);
EVP_PKEY_free(mykey);
cert = new pki_x509(mycert);
X509_free(mycert);
if (mykey) {
key = new pki_key(mykey);
key->setDescription("pk12-import");
//EVP_PKEY_free(mykey);
}
if (mycert) {
cert = new pki_x509(mycert);
cert->setDescription("pk12-import");
//X509_free(mycert);
}
}
else pki_error("Error opening file");
}
@ -93,13 +107,15 @@ pki_pkcs12::pki_pkcs12(const string fname, pem_password_cb *cb)
pki_pkcs12::~pki_pkcs12()
{
sk_X509_pop_free(certstack, X509_free); // free the certs itself, because we own a copy of them
delete(key);
delete(cert);
PKCS12_free(pkcs12);
}
void pki_pkcs12::addCaCert(pki_x509 *ca)
{
if (ca == 0) return;
if (!ca) return;
sk_X509_push(certstack, X509_dup(ca->getCert()));
}
@ -135,21 +151,24 @@ void pki_pkcs12::writePKCS12(const string fname)
else pki_error("Error opening file");
}
int pki_pkcs12::num_ca() {
int pki_pkcs12::numCa() {
return sk_X509_num(certstack);
}
pki_key *pki_pkcs12::getKey() {
return key;
return new pki_key(key);
}
pki_x509 *pki_pkcs12::getCert() {
return cert;
return new pki_x509(cert);
}
pki_x509 *pki_pkcs12::getCa(int x) {
return new pki_x509(sk_X509_value(certstack, x));
pki_x509 *cert;
cert = new pki_x509(X509_dup(sk_X509_value(certstack, x)));
cert->setDescription("pk12-import");
return cert;
}

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/
@ -85,7 +86,7 @@ class pki_pkcs12: public pki_base
pki_key *getKey();
pki_x509 *getCert();
pki_x509 *getCa(int x);
int num_ca(); // number of ca certs;
int numCa(); // number of ca certs;
//bool fromData(unsigned char *p, int size);
//unsigned char *toData(int *size);
//bool compare(pki_base *ref);

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/

View File

@ -44,6 +44,7 @@
* http://www.hohnstaedt.de/xca
* email: christian@hohnstaedt.de
*
* $id$
*
*/