Panda3D
 All Classes Functions Variables Enumerations
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 #include "filename.h"
00022 
00023 #ifdef _WIN32
00024 #include <winsock2.h>  // must be included prior to including OpenSSL.
00025 #endif
00026 
00027 #define OPENSSL_NO_KRB5
00028 #include "openssl/ssl.h"
00029 #include "openssl/rand.h"
00030 #include "openssl/err.h"
00031 #include "openssl/x509.h"
00032 #include "openssl/x509v3.h"
00033 
00034 // Windows may define this macro inappropriately.
00035 #ifdef X509_NAME
00036 #undef X509_NAME
00037 #endif
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //       Class : OpenSSLWrapper
00041 // Description : Provides an interface wrapper around the OpenSSL
00042 //               library, to ensure that the library is properly
00043 //               initialized in the application, and to provide some
00044 //               hooks into global OpenSSL context data.
00045 ////////////////////////////////////////////////////////////////////
00046 class EXPCL_PANDAEXPRESS OpenSSLWrapper {
00047 private:
00048   OpenSSLWrapper();
00049   ~OpenSSLWrapper();
00050 
00051 public:
00052   void clear_certificates();
00053   int load_certificates(const Filename &filename);
00054   int load_certificates_from_pem_ram(const char *data, size_t data_size);
00055   int load_certificates_from_der_ram(const char *data, size_t data_size);
00056 
00057   X509_STORE *get_x509_store();
00058 
00059   void notify_ssl_errors();
00060   void notify_debug_ssl_errors();
00061 
00062   static OpenSSLWrapper *get_global_ptr();
00063 
00064 private:
00065   X509_STORE *_x509_store;
00066 
00067   static OpenSSLWrapper *_global_ptr;
00068 };
00069 
00070 #include "openSSLWrapper.I"
00071 
00072 #endif  // HAVE_OPENSSL
00073 #endif
 All Classes Functions Variables Enumerations