Panda3D
 All Classes Functions Variables Enumerations
openSSLWrapper.h
1 // Filename: openSSLWrapper.h
2 // Created by: drose (05Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef OPENSSLWRAPPER_H
16 #define OPENSSLWRAPPER_H
17 
18 #include "pandabase.h"
19 
20 #ifdef HAVE_OPENSSL
21 #include "filename.h"
22 
23 #ifdef _WIN32
24 #include <winsock2.h> // must be included prior to including OpenSSL.
25 #endif
26 
27 #define OPENSSL_NO_KRB5
28 #include "openssl/ssl.h"
29 #include "openssl/rand.h"
30 #include "openssl/err.h"
31 #include "openssl/x509.h"
32 #include "openssl/x509v3.h"
33 
34 // Windows may define this macro inappropriately.
35 #ifdef X509_NAME
36 #undef X509_NAME
37 #endif
38 
39 ////////////////////////////////////////////////////////////////////
40 // Class : OpenSSLWrapper
41 // Description : Provides an interface wrapper around the OpenSSL
42 // library, to ensure that the library is properly
43 // initialized in the application, and to provide some
44 // hooks into global OpenSSL context data.
45 ////////////////////////////////////////////////////////////////////
46 class EXPCL_PANDAEXPRESS OpenSSLWrapper {
47 private:
48  OpenSSLWrapper();
49  ~OpenSSLWrapper();
50 
51 PUBLISHED:
52  void clear_certificates();
53  int load_certificates(const Filename &filename);
54  int load_certificates_from_pem_ram(const char *data, size_t data_size);
55  int load_certificates_from_der_ram(const char *data, size_t data_size);
56 
57  INLINE int load_certificates_from_pem_ram(const string &data);
58  INLINE int load_certificates_from_der_ram(const string &data);
59 
60  X509_STORE *get_x509_store();
61 
62  void notify_ssl_errors();
63  void notify_debug_ssl_errors();
64 
65  static OpenSSLWrapper *get_global_ptr();
66 
67 private:
68  X509_STORE *_x509_store;
69 
70  static OpenSSLWrapper *_global_ptr;
71 };
72 
73 #include "openSSLWrapper.I"
74 
75 #endif // HAVE_OPENSSL
76 #endif
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44