@@ -188,10 +188,10 @@ OSSLContext::~OSSLContext() {
188188
189189void OSSLContext::reset () {
190190 if (ctx_) {
191- // The SSL object inside the ngtcp2 ctx may not have been set if
192- // SSL creation failed. Guard against null before clearing app data.
193- if ( SSL * ssl = * this ; ssl != nullptr ) {
194- SSL_set_app_data (ssl, nullptr );
191+ if (ssl_) {
192+ SSL_set_app_data (ssl_. get (), nullptr );
193+ ngtcp2_crypto_ossl_ctx_set_ssl (ctx_, nullptr );
194+ ssl_. reset ( );
195195 }
196196 // connection_ is set during Initialize(). If Initialize() was
197197 // never called (e.g. SSL creation failed), it's still nullptr.
@@ -205,19 +205,20 @@ void OSSLContext::reset() {
205205}
206206
207207OSSLContext::operator SSL *() const {
208- return ngtcp2_crypto_ossl_ctx_get_ssl (ctx_ );
208+ return ssl_. get ( );
209209}
210210
211211OSSLContext::operator ngtcp2_crypto_ossl_ctx*() const {
212212 return ctx_;
213213}
214214
215- void OSSLContext::Initialize (SSL * ssl,
215+ void OSSLContext::Initialize (SSLPointer ssl,
216216 ngtcp2_crypto_conn_ref* ref,
217217 ngtcp2_conn* connection,
218218 SSL_CTX * ssl_ctx) {
219219 CHECK (ssl);
220- ngtcp2_crypto_ossl_ctx_set_ssl (ctx_, ssl);
220+ ssl_ = std::move (ssl);
221+ ngtcp2_crypto_ossl_ctx_set_ssl (ctx_, ssl_.get ());
221222 SSL_set_app_data (*this , ref);
222223 // TODO(@jasnell): Later when BoringSSL is also supported, the native
223224 // handle will be different. The ngtcp2_crypto_ossl.h impl requires
@@ -894,7 +895,7 @@ void TLSSession::Initialize(
894895 EnableTrace (session_->env (), &bio_trace_, ssl);
895896 }
896897
897- ossl_context_.Initialize (ssl. release ( ), &ref_, session (), ctx);
898+ ossl_context_.Initialize (std::move (ssl ), &ref_, session (), ctx);
898899
899900 switch (ctx.side ()) {
900901 case Side::SERVER : {
0 commit comments