Panda3D

openSSLWrapper.h

00001 // Filename: openSSLWrapper.h
00002 // Created by:  drose (05Sep09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef OPENSSLWRAPPER_H
00016 #define OPENSSLWRAPPER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #ifdef HAVE_OPENSSL
00021 
00022 #include "filename.h"
00023 
00024 #define OPENSSL_NO_KRB5
00025 #include "openssl/ssl.h"
00026 #include "openssl/rand.h"
00027 #include "openssl/err.h"
00028 #include "openssl/x509.h"
00029 #include "openssl/x509v3.h"
00030 
00031 // Windows may define this macro inappropriately.
00032 #ifdef X509_NAME
00033 #undef X509_NAME
00034 #endif
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : OpenSSLWrapper
00038 // Description : Provides an interface wrapper around the OpenSSL
00039 //               library, to ensure that the library is properly
00040 //               initialized in the application, and to provide some
00041 //               hooks into global OpenSSL context data.
00042 ////////////////////////////////////////////////////////////////////
00043 class EXPCL_PANDAEXPRESS OpenSSLWrapper {
00044 private:
00045   OpenSSLWrapper();
00046   ~OpenSSLWrapper();
00047 
00048 public:
00049   void clear_certificates();
00050   int load_certificates(const Filename &filename);
00051   int load_certificates_from_pem_ram(const char *data, size_t data_size);
00052   int load_certificates_from_der_ram(const char *data, size_t data_size);
00053 
00054   X509_STORE *get_x509_store();
00055 
00056   void notify_ssl_errors();
00057   void notify_debug_ssl_errors();
00058 
00059   static OpenSSLWrapper *get_global_ptr();
00060 
00061 private:
00062   X509_STORE *_x509_store;
00063 
00064   static OpenSSLWrapper *_global_ptr;
00065 };
00066 
00067 #include "openSSLWrapper.I"
00068 
00069 #endif  // HAVE_OPENSSL
00070 #endif
 All Classes Functions Variables Enumerations