KIO
Go to the documentation of this file.
23 #include <ksslconfig.h>
27 #include <QtCore/QString>
28 #include <QtCore/QFile>
38 #define sk_new kossl->sk_new
39 #define sk_push kossl->sk_push
40 #define sk_free kossl->sk_free
41 #define sk_value kossl->sk_value
42 #define sk_num kossl->sk_num
43 #define sk_dup kossl->sk_dup
44 #define sk_pop kossl->sk_pop
53 kossl = KOSSL::self();
60 if (_pkey) kossl->EVP_PKEY_free(_pkey);
63 X509* x5 = sk_X509_pop(_caStack);
67 sk_X509_free(_caStack);
69 if (_pkcs) kossl->PKCS12_free(_pkcs);
80 if (base64.isEmpty())
return NULL;
81 QByteArray qba = QByteArray::fromBase64(base64.toLatin1());
95 PKCS12 *newpkcs = NULL;
97 if (!qf.open(QIODevice::ReadOnly))
100 FILE *
fp = fdopen(qf.handle(),
"r");
101 if (!
fp)
return NULL;
103 newpkcs = KOSSL::self()->d2i_PKCS12_fp(
fp, &newpkcs);
107 KOSSL::self()->ERR_clear_error();
115 if (!c->
parse(password)) {
135 return (0 == kossl->PKCS12_newpass(_pkcs,
136 pold.isNull() ? (
char *)
"" : (
char *)pold.toLatin1().constData(),
137 pnew.isNull() ? (
char *)
"" : (
char *)pnew.toLatin1().constData()));
150 if (_pkey) kossl->EVP_PKEY_free(_pkey);
153 X509* x5 = sk_X509_pop(_caStack);
155 kossl->X509_free(x5);
157 sk_X509_free(_caStack);
163 int rc = kossl->PKCS12_parse(_pkcs, pass.toLatin1(), &_pkey, &x, &_caStack);
178 kossl->ERR_clear_error();
202 len = kossl->i2d_PKCS12(_pkcs, NULL);
204 char *buf =
new char[len];
205 p = (
unsigned char *)buf;
206 kossl->i2d_PKCS12(_pkcs, &p);
207 base64 = QByteArray::fromRawData(buf, len).toBase64();
220 if (!out.open(QIODevice::WriteOnly))
return false;
222 int fd = out.handle();
223 FILE *
fp = fdopen(fd,
"w");
226 unlink(filename.toLatin1());
230 kossl->i2d_PKCS12_fp(
fp, _pkcs);
247 if (1 != kossl->X509_check_private_key(_cert->
getCert(), _pkey)) {
static KSSLPKCS12 * loadCertFile(const QString &filename, const QString &password=QLatin1String(""))
Create a KSSLPKCS12 object by reading a PKCS#12 file.
KSSLValidation validate()
Check if this is a valid certificate.
static KSSLPKCS12 * fromString(const QString &base64, const QString &password=QLatin1String(""))
Create a KSSLPKCS12 object from a Base64 in a QString.
KSSLValidation
Result of the validate() call.
EVP_PKEY * getPrivateKey()
Get the private key.
KSSLCertificate * getCertificate()
Get the X.509 certificate.
bool isValid()
Check if the X.509 and private key are valid.
bool toFile(const QString &filename)
Write the PKCS#12 to a file in raw mode.
QString name() const
The name of this certificate.
virtual ~KSSLPKCS12()
Destroy this PKCS#12 certificate.
void setCert(PKCS12 *c)
Raw set the PKCS12 object.
bool parse(const QString &pass)
bool setCert(const QString &cert)
Re-set the certificate from a base64 string.
QString getSubject() const
Get the subject of the certificate (X.509 map).
bool changePassword(const QString &pold, const QString &pnew)
Change the password of the PKCS#12 in memory.
KSSLCertificate::KSSLValidation validate()
Check the X.509 and private key to make sure they're valid.
QString toString()
Convert to a Base64 string.
KSSLCertificate::KSSLValidation revalidate()
Check the X.509 and private key to make sure they're valid.
KSSLValidation revalidate()
Check if this is a valid certificate.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jan 19 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.