File indexing completed on 2024-04-21 14:56:08

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef _KSSLCERTCHAIN_H
0022 #define _KSSLCERTCHAIN_H
0023 
0024 #include <QList>
0025 
0026 class QString;
0027 class KSSL;
0028 class KSSLCertChainPrivate;
0029 class QStringList;
0030 
0031 #include <ksslcertificate.h>
0032 
0033 /**
0034  * KDE Certificate Chain Representation Class
0035  *
0036  * This class provides a representation for an X.509 certificate chain.
0037  *
0038  * @author George Staikos <staikos@kde.org>
0039  * @see KSSL, KSSLCertificate, KSSLPeerInfo
0040  * @short KDE X.509 Certificate Chain
0041  */
0042 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KSSLCertChain
0043 {
0044     friend class KSSL;
0045     friend class KSSLPeerInfo;
0046 
0047 public:
0048     /**
0049      *  Construct a KSSLCertChain object
0050      */
0051     KSSLCertChain();
0052 
0053     /**
0054      *  Destroy this KSSLCertChain object
0055      */
0056     ~KSSLCertChain();
0057 
0058     /**
0059      *  Determine if this represents a valid certificate chain
0060      *
0061      *  @return true if it is a valid certificate chain
0062      */
0063     bool isValid();
0064 
0065     /**
0066      *  Do a deep copy of the certificate chain.
0067      *
0068      *  @return pointer to a new certificate chain object
0069      *
0070      *  This is an expensive operation, and you are responsible for deleting
0071      *  the returned object yourself.
0072      */
0073     KSSLCertChain *replicate();
0074 
0075     /**
0076      *  Set the raw chain from OpenSSL
0077      *  @internal
0078      */
0079     void setChain(void *stack_of_x509);
0080 
0081     /**
0082      *  Set the certificate chain as a pointer list of KSSL certificates.
0083      *
0084      *  @param chain the certificate chain
0085      *  @see KSSLCertificate
0086      */
0087     void setChain(const QList<KSSLCertificate *> &chain);
0088 
0089     /**
0090      *  Set the certificate chain as a list of base64 encoded X.509
0091      *  certificates.
0092      *
0093      *  @param chain the certificate chain
0094      */
0095     void setCertChain(const QStringList &chain);
0096 
0097     /**
0098      *  Obtain a copy of the certificate chain.
0099      *  The caller is responsible for deleting all certificates in the chain.
0100      *
0101      *  @return a deep copy of the certificate chain.
0102      *  @see KSSLCertificate
0103      */
0104     QList<KSSLCertificate *> getChain() const;
0105 
0106     /**
0107      *  Determine the number of entries (depth) of the chain.
0108      *
0109      *  @return the number of entries in the certificate chain
0110      */
0111     int depth();
0112 
0113     /**
0114      *  Read the raw chain in OpenSSL format
0115      *  @internal
0116      */
0117     void *rawChain();
0118 
0119 private:
0120     KSSLCertChainPrivate *const d;
0121     void *_chain;
0122 };
0123 
0124 #endif
0125