@@ -337,6 +337,9 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) { |
337 | 337 | return; |
338 | 338 | } |
339 | 339 |
|
| 340 | + if (wrap->ssl_ == nullptr) |
| 341 | + return; |
| 342 | + |
340 | 343 | // Commit |
341 | 344 | NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_); |
342 | 345 |
|
@@ -554,6 +557,7 @@ int TLSWrap::DoWrite(WriteWrap* w, |
554 | 557 | size_t count, |
555 | 558 | uv_stream_t* send_handle) { |
556 | 559 | CHECK_EQ(send_handle, nullptr); |
| 560 | + CHECK_NE(ssl_, nullptr); |
557 | 561 |
|
558 | 562 | bool empty = true; |
559 | 563 |
|
@@ -627,6 +631,11 @@ void TLSWrap::OnAfterWriteImpl(WriteWrap* w, void* ctx) { |
627 | 631 | void TLSWrap::OnAllocImpl(size_t suggested_size, uv_buf_t* buf, void* ctx) { |
628 | 632 | TLSWrap* wrap = static_cast<TLSWrap*>(ctx); |
629 | 633 |
|
| 634 | + if (wrap->ssl_ == nullptr) { |
| 635 | + *buf = uv_buf_init(nullptr, 0); |
| 636 | + return; |
| 637 | + } |
| 638 | + |
630 | 639 | size_t size = 0; |
631 | 640 | buf->base = NodeBIO::FromBIO(wrap->enc_in_)->PeekWritable(&size); |
632 | 641 | buf->len = size; |
@@ -747,6 +756,10 @@ void TLSWrap::SetVerifyMode(const FunctionCallbackInfo<Value>& args) { |
747 | 756 | void TLSWrap::EnableSessionCallbacks( |
748 | 757 | const FunctionCallbackInfo<Value>& args) { |
749 | 758 | TLSWrap* wrap = Unwrap<TLSWrap>(args.Holder()); |
| 759 | + if (wrap->ssl_ == nullptr) { |
| 760 | + return wrap->env()->ThrowTypeError( |
| 761 | + "EnableSessionCallbacks after destroySSL"); |
| 762 | + } |
750 | 763 | wrap->enable_session_callbacks(); |
751 | 764 | NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength); |
752 | 765 | wrap->hello_parser_.Start(SSLWrap<TLSWrap>::OnClientHello, |
|