Browse Source

Expose OpenSSLWrapper to Python (as requested)

rdb 11 years ago
parent
commit
3c30c8de56
2 changed files with 40 additions and 1 deletions
  1. 36 0
      panda/src/express/openSSLWrapper.I
  2. 4 1
      panda/src/express/openSSLWrapper.h

+ 36 - 0
panda/src/express/openSSLWrapper.I

@@ -12,3 +12,39 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: OpenSSLWrapper::load_certificates_from_pem_ram
+//       Access: Public
+//  Description: Reads a chain of trusted certificates from the
+//               indicated data buffer and adds them to the X509_STORE
+//               object.  The data buffer should be PEM-formatted.
+//               Returns the number of certificates read on success,
+//               or 0 on failure.
+//
+//               You should call this only with trusted,
+//               locally-stored certificates; not with certificates
+//               received from an untrusted source.
+////////////////////////////////////////////////////////////////////
+INLINE int OpenSSLWrapper::
+load_certificates_from_pem_ram(const string &data) {
+  return load_certificates_from_pem_ram(data.data(), data.size());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: OpenSSLWrapper::load_certificates_from_der_ram
+//       Access: Public
+//  Description: Reads a chain of trusted certificates from the
+//               indicated data buffer and adds them to the X509_STORE
+//               object.  The data buffer should be DER-formatted.
+//               Returns the number of certificates read on success,
+//               or 0 on failure.
+//
+//               You should call this only with trusted,
+//               locally-stored certificates; not with certificates
+//               received from an untrusted source.
+////////////////////////////////////////////////////////////////////
+INLINE int OpenSSLWrapper::
+load_certificates_from_der_ram(const string &data) {
+  return load_certificates_from_der_ram(data.data(), data.size());
+}

+ 4 - 1
panda/src/express/openSSLWrapper.h

@@ -48,12 +48,15 @@ private:
   OpenSSLWrapper();
   ~OpenSSLWrapper();
 
-public:
+PUBLISHED:
   void clear_certificates();
   int load_certificates(const Filename &filename);
   int load_certificates_from_pem_ram(const char *data, size_t data_size);
   int load_certificates_from_der_ram(const char *data, size_t data_size);
 
+  INLINE int load_certificates_from_pem_ram(const string &data);
+  INLINE int load_certificates_from_der_ram(const string &data);
+
   X509_STORE *get_x509_store();
 
   void notify_ssl_errors();