25 #include "ksslcertificate.h" 26 #include "ksslcertchain.h" 31 #define crypt _openssl_crypt 32 #include <openssl/ssl.h> 33 #include <openssl/x509.h> 34 #include <openssl/x509v3.h> 35 #include <openssl/x509_vfy.h> 36 #include <openssl/pem.h> 37 #include <openssl/stack.h> 38 #include <openssl/safestack.h> 44 #include <tqstringlist.h> 49 #define sk_new d->kossl->sk_new 50 #define sk_push d->kossl->sk_push 51 #define sk_free d->kossl->sk_free 52 #define sk_value d->kossl->sk_value 53 #define sk_num d->kossl->sk_num 54 #define sk_dup d->kossl->sk_dup 55 #define sk_pop d->kossl->sk_pop 58 class KSSLCertChainPrivate {
60 KSSLCertChainPrivate() {
61 kossl = KOSSL::self();
64 ~KSSLCertChainPrivate() {
71 d =
new KSSLCertChainPrivate;
79 STACK_OF(X509) *x = (STACK_OF(X509) *)_chain;
82 X509* x5 = sk_X509_pop(x);
84 d->kossl->X509_free(x5);
94 return (_chain && depth() > 0);
100 TQPtrList<KSSLCertificate> ch = getChain();
103 ch.setAutoDelete(
true);
110 return sk_X509_num((STACK_OF(X509)*)_chain);
117 TQPtrList<KSSLCertificate> cl;
118 if (!_chain)
return cl;
120 STACK_OF(X509) *x = (STACK_OF(X509) *)_chain;
122 for (
int i = 0; i < sk_X509_num(x); i++) {
123 X509* x5 = sk_X509_value(x, i);
126 nc->
setCert(d->kossl->X509_dup(x5));
138 STACK_OF(X509) *x = (STACK_OF(X509) *)_chain;
141 X509* x5 = sk_X509_pop(x);
143 d->kossl->X509_free(x5);
149 if (chain.count() == 0)
return;
150 _chain = (
void *)sk_new(NULL);
152 sk_X509_push((STACK_OF(X509)*)_chain, d->kossl->X509_dup(x->getCert()));
162 STACK_OF(X509) *x = (STACK_OF(X509) *)_chain;
165 X509* x5 = sk_X509_pop(x);
167 d->kossl->X509_free(x5);
173 if (!stack_of_x509)
return;
175 _chain = (
void *)sk_new(NULL);
176 STACK_OF(X509) *x = (STACK_OF(X509) *)stack_of_x509;
178 for (
int i = 0; i < sk_X509_num(x); i++) {
179 X509* x5 = sk_X509_value(x, i);
181 sk_X509_push((STACK_OF(X509)*)_chain,d->kossl->X509_dup(x5));
195 TQPtrList<KSSLCertificate> cl;
196 cl.setAutoDelete(
true);
197 for (TQStringList::ConstIterator s = chain.begin(); s != chain.end(); ++s) {
void setCertChain(const TQStringList &chain)
Set the certificate chain as a list of base64 encoded X.509 certificates.
KSSLCertChain()
Construct a KSSLCertChain object.
bool setCert(TQString &cert)
Re-set the certificate from a base64 string.
~KSSLCertChain()
Destroy this KSSLCertChain object.
void setChain(void *stack_of_x509)
Set the raw chain from OpenSSL.
KDE Certificate Chain Representation Class.
KSSLCertChain * replicate()
Do a deep copy of the certificate chain.
static KSSLCertificate * fromString(TQCString cert)
Create an X.509 certificate from a base64 encoded string.
int depth()
Determine the number of entries (depth) of the chain.
bool isValid()
Determine if this represents a valid certificate chain.
TQPtrList< KSSLCertificate > getChain()
Obtain a copy of the certificate chain.