KIO
ksslpkcs12.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2001 George Staikos <staikos@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef _KSSLPKCS12_H 00022 #define _KSSLPKCS12_H 00023 00024 #include <ksslconfig.h> 00025 00026 #ifdef KSSL_HAVE_SSL 00027 #define crypt _openssl_crypt 00028 #include <openssl/pkcs12.h> 00029 #undef crypt 00030 #else 00031 class PKCS12; 00032 class EVP_PKEY; 00033 #if !defined(QT_NO_OPENSSL) 00034 #include <QtNetwork/QSslCertificate> 00035 #else 00036 class X509; 00037 #endif 00038 #endif 00039 00040 #include <ksslcertificate.h> 00041 #include <ksslcertchain.h> 00042 00043 #include <QtCore/QString> 00044 00045 #ifndef STACK_OF 00046 #define STACK_OF(x) void 00047 #endif 00048 00049 class KSSL; 00050 class KSSLPKCS12Private; 00051 class KOpenSSLProxy; 00052 00063 class KIO_EXPORT KSSLPKCS12 { 00064 friend class KSSL; 00065 00066 public: 00070 virtual ~KSSLPKCS12(); 00071 00077 QString name() const; 00078 00085 static KSSLPKCS12* fromString(const QString &base64, const QString &password = QLatin1String("")); 00086 00093 static KSSLPKCS12* loadCertFile(const QString &filename, const QString &password = QLatin1String("")); 00094 00099 QString toString(); 00100 00106 void setCert(PKCS12 *c); 00107 00114 bool changePassword(const QString &pold, const QString &pnew); 00115 00121 EVP_PKEY *getPrivateKey(); 00122 00127 KSSLCertificate *getCertificate(); 00128 00134 bool toFile(const QString &filename); 00135 00141 KSSLCertificate::KSSLValidation validate(); 00142 00149 KSSLCertificate::KSSLValidation validate(KSSLCertificate::KSSLPurpose p); 00150 00157 KSSLCertificate::KSSLValidation revalidate(); 00158 00166 KSSLCertificate::KSSLValidation revalidate(KSSLCertificate::KSSLPurpose p); 00167 00172 bool isValid(); 00173 00179 bool isValid(KSSLCertificate::KSSLPurpose p); 00180 00181 protected: 00182 KSSLPKCS12(); 00183 bool parse(const QString &pass); 00184 00185 private: 00186 KSSLPKCS12Private *d; 00187 PKCS12 *_pkcs; 00188 KOpenSSLProxy *kossl; 00189 EVP_PKEY *_pkey; 00190 KSSLCertificate *_cert; 00191 STACK_OF(X509) *_caStack; 00192 }; 00193 00194 00195 #endif 00196