KIO
Go to the documentation of this file.
24 #include <ksslconfig.h>
32 #define crypt _openssl_crypt
33 #include <openssl/ssl.h>
34 #include <openssl/x509.h>
35 #include <openssl/x509v3.h>
36 #include <openssl/x509_vfy.h>
37 #include <openssl/pem.h>
38 #include <openssl/stack.h>
39 #include <openssl/safestack.h>
45 #include <QtCore/QStringList>
47 class KSSLCertChainPrivate {
49 KSSLCertChainPrivate() {
50 kossl = KOSSL::self();
53 ~KSSLCertChainPrivate() {
60 :d(new KSSLCertChainPrivate)
72 X509 *x5 =
reinterpret_cast<X509*
>(d->kossl->OPENSSL_sk_pop(
reinterpret_cast<STACK *
>(x)));
74 d->kossl->X509_free(x5);
76 d->kossl->OPENSSL_sk_free(
reinterpret_cast<STACK *
>(x));
84 return (_chain &&
depth() > 0);
99 return d->kossl->OPENSSL_sk_num(
static_cast<STACK *
>(_chain));
112 if (!_chain)
return cl;
116 for (
int i = 0; i < d->kossl->OPENSSL_sk_num(
reinterpret_cast<STACK *
>(x)); i++) {
117 X509 *x5 =
reinterpret_cast<X509*
>(d->kossl->OPENSSL_sk_value(
reinterpret_cast<STACK *
>(x), i));
120 nc->
setCert(d->kossl->X509_dup(x5));
135 X509 *x5 =
reinterpret_cast<X509*
>(d->kossl->OPENSSL_sk_pop(
reinterpret_cast<STACK*
>(x)));
137 d->kossl->X509_free(x5);
139 d->kossl->OPENSSL_sk_free(
reinterpret_cast<STACK*
>(x));
143 if (chain.isEmpty())
return;
144 _chain = (
void *)d->kossl->OPENSSL_sk_new(NULL);
146 d->kossl->OPENSSL_sk_push(
static_cast<STACK*
>(_chain), d->kossl->X509_dup(x->
getCert()));
159 X509 *x5 =
reinterpret_cast<X509 *
>(d->kossl->OPENSSL_sk_pop(
reinterpret_cast<STACK *
>(x)));
161 d->kossl->X509_free(x5);
163 d->kossl->OPENSSL_sk_free(
reinterpret_cast<STACK *
>(x));
167 if (!stack_of_x509)
return;
169 _chain = (
void *)d->kossl->OPENSSL_sk_new(NULL);
172 for (
int i = 0; i < d->kossl->OPENSSL_sk_num(
reinterpret_cast<STACK *
>(x)); i++) {
173 X509 *x5 =
reinterpret_cast<X509*
>(d->kossl->OPENSSL_sk_value(
reinterpret_cast<STACK *
>(x), i));
175 d->kossl->OPENSSL_sk_push(
reinterpret_cast<STACK *
>(_chain), d->kossl->X509_dup(x5));
186 for (QStringList::ConstIterator s = chain.begin(); s != chain.end(); ++s) {
QList< KSSLCertificate * > getChain() const
Obtain a copy of the certificate chain.
void setChain(void *stack_of_x509)
Set the raw chain from OpenSSL.
void setCertChain(const QStringList &chain)
Set the certificate chain as a list of base64 encoded X.509 certificates.
void * rawChain()
Read the raw chain in OpenSSL format.
static KSSLCertificate * fromString(const QByteArray &cert)
Create an X.509 certificate from a base64 encoded string.
int depth()
Determine the number of entries (depth) of the chain.
KSSLCertChain * replicate()
Do a deep copy of the certificate chain.
~KSSLCertChain()
Destroy this KSSLCertChain object.
KDE Certificate Chain Representation Class.
bool isValid()
Determine if this represents a valid certificate chain.
bool setCert(const QString &cert)
Re-set the certificate from a base64 string.
KSSLCertChain()
Construct a KSSLCertChain object.
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.