Commit 298db23e authored by Kenton Varda's avatar Kenton Varda

Conditionally support OpenSSL back to 1.0.2.

parent d624d56e
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
#include <kj/debug.h> #include <kj/debug.h>
#include <kj/vector.h> #include <kj/vector.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define BIO_set_init(x,v) (x->init=v)
#define BIO_get_data(x) (x->ptr)
#define BIO_set_data(x,v) (x->ptr=v)
#endif
namespace kj { namespace kj {
namespace { namespace {
...@@ -333,11 +339,28 @@ private: ...@@ -333,11 +339,28 @@ private:
return 1; return 1;
} }
static BIO_METHOD* getBioVtable() { #if OPENSSL_VERSION_NUMBER < 0x10100000L
static BIO_METHOD* vtable = makeBioVtable(); static const BIO_METHOD* getBioVtable() {
static const BIO_METHOD VTABLE {
BIO_TYPE_SOURCE_SINK,
"KJ stream",
TlsConnection::bioWrite,
TlsConnection::bioRead,
nullptr, // puts
nullptr, // gets
TlsConnection::bioCtrl,
TlsConnection::bioCreate,
TlsConnection::bioDestroy,
nullptr
};
return &VTABLE;
}
#else
static const BIO_METHOD* getBioVtable() {
static const BIO_METHOD* const vtable = makeBioVtable();
return vtable; return vtable;
} }
static BIO_METHOD* makeBioVtable() { static const BIO_METHOD* makeBioVtable() {
BIO_METHOD* vtable = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "KJ stream"); BIO_METHOD* vtable = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "KJ stream");
BIO_meth_set_write(vtable, TlsConnection::bioWrite); BIO_meth_set_write(vtable, TlsConnection::bioWrite);
BIO_meth_set_read(vtable, TlsConnection::bioRead); BIO_meth_set_read(vtable, TlsConnection::bioRead);
...@@ -346,6 +369,7 @@ private: ...@@ -346,6 +369,7 @@ private:
BIO_meth_set_destroy(vtable, TlsConnection::bioDestroy); BIO_meth_set_destroy(vtable, TlsConnection::bioDestroy);
return vtable; return vtable;
} }
#endif
}; };
// ======================================================================================= // =======================================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment