From 3c30c8de56ca4b6f60fe5c35e8700fb4badea293 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Jan 2015 23:04:48 +0100 Subject: [PATCH] Expose OpenSSLWrapper to Python (as requested) --- panda/src/express/openSSLWrapper.I | 36 ++++++++++++++++++++++++++++++ panda/src/express/openSSLWrapper.h | 5 ++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/panda/src/express/openSSLWrapper.I b/panda/src/express/openSSLWrapper.I index c7e12551c7..e90339034e 100644 --- a/panda/src/express/openSSLWrapper.I +++ b/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()); +} diff --git a/panda/src/express/openSSLWrapper.h b/panda/src/express/openSSLWrapper.h index 4e277d881a..ee473dbcc6 100644 --- a/panda/src/express/openSSLWrapper.h +++ b/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();