TargetedCertificateManager.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2002-2009 Moxie Marlinspike
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. */
  19. #ifndef __TARGETED_CERTIFICATE_MANAGER_H__
  20. #define __TARGETED_CERTIFICATE_MANAGER_H__
  21. #include <list>
  22. #include <openssl/pem.h>
  23. #include <openssl/conf.h>
  24. #include <openssl/x509v3.h>
  25. #include <openssl/ssl.h>
  26. #include <openssl/err.h>
  27. #include <openssl/rand.h>
  28. #include <string>
  29. #include <boost/filesystem.hpp>
  30. #include "Certificate.hpp"
  31. #include "CertificateManager.hpp"
  32. using namespace boost::filesystem;
  33. class TargetedCertificateManager : public CertificateManager {
  34. private:
  35. // Certificate *chain;
  36. std::list<Certificate*> chainList;
  37. std::list<Certificate*> certificates;
  38. public:
  39. TargetedCertificateManager(std::string &directory, std::string &chain);
  40. void dump();
  41. bool isUpdateTarget(boost::asio::ip::tcp::endpoint &endpoint);
  42. virtual bool isOCSPAddress(boost::asio::ip::tcp::endpoint &endpoint);
  43. virtual bool isValidTarget(boost::asio::ip::tcp::endpoint &endpoint, bool wildcardOK);
  44. virtual void getCertificateForTarget(boost::asio::ip::tcp::endpoint &endpoint,
  45. bool wildcardOK,
  46. X509 *serverCertificate,
  47. Certificate **cert,
  48. std::list<Certificate*> **chainCerts);
  49. };
  50. class NoCertificateDirectoryException : public std::exception {
  51. public:
  52. virtual const char* what() const throw() {
  53. return "No such directory...";
  54. }
  55. };
  56. #endif