mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Additional attributes when printing PKCS#12 content
This commit is contained in:
parent
7206024d6a
commit
d606254f7a
@ -417,7 +417,8 @@ void pki_base::print(BioByteArray &bba, enum print_opt opt) const
|
||||
"Not Before", "Not After", "Verify Ok",
|
||||
"Unstructured Name", "Challange Password",
|
||||
"Last Update", "Next Update", "CA", "Self signed",
|
||||
"Key", "Signature", "Extensions", "Comment",
|
||||
"Key", "Signature", "Extensions", "Comment", "Algorithm",
|
||||
"Friendly Name"
|
||||
};
|
||||
if (opt == print_coloured) {
|
||||
QMap<QString, QString> prp;
|
||||
|
||||
@ -171,10 +171,15 @@ void pki_multi::probeAnything(const QString &fname)
|
||||
|
||||
void pki_multi::print(BioByteArray &bba, enum print_opt opt) const
|
||||
{
|
||||
pki_base::print(bba, opt);
|
||||
foreach(pki_base *pki, multi)
|
||||
pki->print(bba, opt);
|
||||
}
|
||||
|
||||
void pki_multi::collect_properties(QMap<QString, QString> &prp) const
|
||||
{
|
||||
}
|
||||
|
||||
QList<pki_base *> pki_multi::pull()
|
||||
{
|
||||
QList<pki_base*> temp = multi;
|
||||
|
||||
@ -26,6 +26,7 @@ class pki_multi: public pki_base
|
||||
void probeAnything(const QString &fname);
|
||||
void append_item(pki_base *pki);
|
||||
void print(BioByteArray &b, enum print_opt opt) const;
|
||||
void collect_properties(QMap<QString, QString> &prp) const;
|
||||
QList<pki_base *> pull();
|
||||
QList<pki_base *> get() const;
|
||||
};
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/stack.h>
|
||||
|
||||
pki_pkcs12::pki_pkcs12(const QString &d, pki_x509 *acert, pki_key *akey)
|
||||
@ -35,6 +36,9 @@ pki_pkcs12::pki_pkcs12(const QString &fname)
|
||||
X509 *mycert = NULL;
|
||||
key = NULL; cert = NULL;
|
||||
pass_info p(XCA_TITLE, tr("Please enter the password to decrypt the PKCS#12 file:\n%1").arg(compressFilename(fname)));
|
||||
const X509_ALGOR *macalgid = NULL;
|
||||
const ASN1_INTEGER *maciter = NULL;
|
||||
const ASN1_OBJECT *macobj = NULL;
|
||||
|
||||
setFilename(fname);
|
||||
XFile file(fname);
|
||||
@ -48,6 +52,14 @@ pki_pkcs12::pki_pkcs12(const QString &fname)
|
||||
throw errorEx(tr("Unable to load the PKCS#12 (pfx) file %1.")
|
||||
.arg(fname));
|
||||
}
|
||||
PKCS12_get0_mac(NULL, &macalgid, NULL, &maciter, pkcs12);
|
||||
if (macalgid)
|
||||
X509_ALGOR_get0(&macobj, NULL, NULL, macalgid);
|
||||
if (macobj) {
|
||||
algorithm = OBJ_obj2QString(macobj);
|
||||
if (maciter)
|
||||
algorithm += QString(", iteration %1").arg(a1int(maciter).toDec());
|
||||
}
|
||||
while (!PKCS12_verify_mac(pkcs12, pass.constData(), pass.size())) {
|
||||
if (pass.size() > 0)
|
||||
XCA_PASSWD_ERROR();
|
||||
@ -150,6 +162,13 @@ void pki_pkcs12::writePKCS12(XFile &file, encAlgo &encAlgo) const
|
||||
file.write(b);
|
||||
}
|
||||
|
||||
void pki_pkcs12::collect_properties(QMap<QString, QString> &prp) const
|
||||
{
|
||||
if (!algorithm.isEmpty())
|
||||
prp["Algorithm"] = algorithm;
|
||||
if (!alias.isEmpty())
|
||||
prp["Friendly Name"] = alias;
|
||||
}
|
||||
|
||||
// see https://www.rfc-editor.org/rfc/rfc8018 Appendix B.2 for possible encryption schemes
|
||||
const QList<int> encAlgo::all_encAlgos(
|
||||
|
||||
@ -41,7 +41,7 @@ class pki_pkcs12: public pki_multi
|
||||
friend class pki_evp;
|
||||
|
||||
protected:
|
||||
QString alias;
|
||||
QString alias, algorithm;
|
||||
pki_x509 *cert;
|
||||
pki_key *key;
|
||||
|
||||
@ -58,5 +58,6 @@ class pki_pkcs12: public pki_multi
|
||||
return cert;
|
||||
}
|
||||
void writePKCS12(XFile &file, encAlgo &encAlgo) const;
|
||||
void collect_properties(QMap<QString, QString> &prp) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user