TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ksslpkcs7.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* This file is part of the KDE project
  2. *
  3. * Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef _KSSLPKCS7_H
  21. #define _KSSLPKCS7_H
  22. #ifdef Q_WS_WIN
  23. #include "ksslconfig_win.h"
  24. #else
  25. #include "ksslconfig.h"
  26. #endif
  27. #ifdef KSSL_HAVE_SSL
  28. #define crypt _openssl_crypt
  29. #include <openssl/pkcs7.h>
  30. #undef crypt
  31. #else
  32. class PKCS7;
  33. class X509;
  34. #endif
  35. //#include <kopenssl.h>
  36. #include <ksslcertificate.h>
  37. #include <ksslcertchain.h>
  38. #ifndef STACK_OF
  39. #define STACK_OF(x) void
  40. #endif
  41. class KSSL;
  42. class KSSLPKCS7Private;
  43. class KOpenSSLProxy;
  44. /**
  45. * KDE PKCS#7 Certificate
  46. *
  47. * This class represents a PKCS#7 certificate
  48. *
  49. * @author George Staikos <staikos@kde.org>
  50. * @see KSSL
  51. * @short KDE PKCS#7 Certificate
  52. */
  53. class TDEIO_EXPORT KSSLPKCS7 {
  54. friend class KSSL;
  55. public:
  56. /**
  57. * Destroy this PKCS#7 certificate
  58. */
  59. virtual ~KSSLPKCS7();
  60. /**
  61. * The name of this certificate. This can be used to refer to the
  62. * certificate instead of passing the object itself.
  63. * @return the name of the certificate
  64. */
  65. TQString name();
  66. /**
  67. * Create a KSSLPKCS7 object from a Base64 in a TQString.
  68. * @param base64 the base64 representation of the certificate
  69. * @return a PKCS#7 object, or NULL on failure
  70. */
  71. static KSSLPKCS7* fromString(TQString base64);
  72. /**
  73. * Create a KSSLPKCS7 object by reading a PKCS#7 file.
  74. * @param filename the filename to read the certificate from
  75. * @return a PKCS#7 object, or NULL on failure
  76. */
  77. static KSSLPKCS7* loadCertFile(TQString filename);
  78. /**
  79. * Convert to a Base64 string.
  80. * @return the PKCS#7 object in base64 form
  81. */
  82. TQString toString();
  83. /**
  84. * Raw set the PKCS7 object.
  85. * @param c the PKCS7 object
  86. * @internal
  87. */
  88. void setCert(PKCS7 *c);
  89. /**
  90. * Get the bottom level X.509 certificate.
  91. * @return the certificate, or NULL on failure
  92. * @see KSSLCertificate
  93. */
  94. KSSLCertificate *getCertificate();
  95. /**
  96. * Get the certificate chain.
  97. * @return the certificate chain
  98. * @see KSSLCertChain
  99. */
  100. KSSLCertChain *getChain();
  101. /**
  102. * Write the PKCS#7 to a file in raw mode.
  103. * @param filename the filename to write
  104. * @return true on success
  105. */
  106. bool toFile(TQString filename);
  107. /**
  108. * Check the chain to make sure it's valid.
  109. * @return the result of the validation procedure
  110. */
  111. KSSLCertificate::KSSLValidation validate();
  112. /**
  113. * Check the chain to make sure it's valid.
  114. * Ignore any cached validation result.
  115. * @return the result of the validation
  116. * @see KSSLCertificate
  117. */
  118. KSSLCertificate::KSSLValidation revalidate();
  119. /**
  120. * Return true if the chain is valid.
  121. */
  122. bool isValid();
  123. protected:
  124. KSSLPKCS7();
  125. private:
  126. KSSLPKCS7Private *d;
  127. PKCS7 *_pkcs;
  128. KOpenSSLProxy *kossl;
  129. KSSLCertificate *_cert;
  130. KSSLCertChain *_chain;
  131. };
  132. #endif