Commit d9b032e6 authored by Kenton Varda's avatar Kenton Varda

Update for recent OpenSSL changes that make certain data structures opaque.

parent 8c5fbab7
...@@ -104,14 +104,14 @@ public: ...@@ -104,14 +104,14 @@ public:
throwOpensslError(); throwOpensslError();
} }
BIO* bio = BIO_new(const_cast<BIO_METHOD*>(&bioVtable)); BIO* bio = BIO_new(const_cast<BIO_METHOD*>(getBioVtable()));
if (bio == nullptr) { if (bio == nullptr) {
SSL_free(ssl); SSL_free(ssl);
throwOpensslError(); throwOpensslError();
} }
bio->ptr = this; BIO_set_data(bio, this);
bio->init = 1; BIO_set_init(bio, 1);
SSL_set_bio(ssl, bio, bio); SSL_set_bio(ssl, bio, bio);
} }
...@@ -288,7 +288,7 @@ private: ...@@ -288,7 +288,7 @@ private:
static int bioRead(BIO* b, char* out, int outl) { static int bioRead(BIO* b, char* out, int outl) {
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
KJ_IF_MAYBE(n, reinterpret_cast<TlsConnection*>(b->ptr)->readBuffer KJ_IF_MAYBE(n, reinterpret_cast<TlsConnection*>(BIO_get_data(b))->readBuffer
.read(kj::arrayPtr(out, outl).asBytes())) { .read(kj::arrayPtr(out, outl).asBytes())) {
return *n; return *n;
} else { } else {
...@@ -299,7 +299,7 @@ private: ...@@ -299,7 +299,7 @@ private:
static int bioWrite(BIO* b, const char* in, int inl) { static int bioWrite(BIO* b, const char* in, int inl) {
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
KJ_IF_MAYBE(n, reinterpret_cast<TlsConnection*>(b->ptr)->writeBuffer KJ_IF_MAYBE(n, reinterpret_cast<TlsConnection*>(BIO_get_data(b))->writeBuffer
.write(kj::arrayPtr(in, inl).asBytes())) { .write(kj::arrayPtr(in, inl).asBytes())) {
return *n; return *n;
} else { } else {
...@@ -323,7 +323,7 @@ private: ...@@ -323,7 +323,7 @@ private:
} }
static int bioCreate(BIO* b) { static int bioCreate(BIO* b) {
b->ptr = nullptr; BIO_set_data(b, nullptr);
return 1; return 1;
} }
...@@ -332,20 +332,19 @@ private: ...@@ -332,20 +332,19 @@ private:
return 1; return 1;
} }
static const BIO_METHOD bioVtable; static BIO_METHOD* getBioVtable() {
}; static BIO_METHOD* vtable = makeBioVtable();
return vtable;
const BIO_METHOD TlsConnection::bioVtable = { }
BIO_TYPE_SOURCE_SINK, static BIO_METHOD* makeBioVtable() {
"KJ stream", BIO_METHOD* vtable = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "KJ stream");
TlsConnection::bioWrite, BIO_meth_set_write(vtable, TlsConnection::bioWrite);
TlsConnection::bioRead, BIO_meth_set_read(vtable, TlsConnection::bioRead);
nullptr, // puts BIO_meth_set_ctrl(vtable, TlsConnection::bioCtrl);
nullptr, // gets BIO_meth_set_create(vtable, TlsConnection::bioCreate);
TlsConnection::bioCtrl, BIO_meth_set_destroy(vtable, TlsConnection::bioDestroy);
TlsConnection::bioCreate, return vtable;
TlsConnection::bioDestroy, }
nullptr
}; };
// ======================================================================================= // =======================================================================================
......
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