File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -116,14 +116,6 @@ static X509_NAME *cnnic_ev_name =
116116 d2i_X509_NAME (nullptr , &cnnic_ev_p,
117117 sizeof (CNNIC_EV_ROOT_CA_SUBJECT_DATA)-1 );
118118
119- // Forcibly clear OpenSSL's error stack on return. This stops stale errors
120- // from popping up later in the lifecycle of crypto operations where they
121- // would cause spurious failures. It's a rather blunt method, though.
122- // ERR_clear_error() isn't necessarily cheap either.
123- struct ClearErrorOnReturn {
124- ~ClearErrorOnReturn () { ERR_clear_error (); }
125- };
126-
127119static uv_mutex_t * locks;
128120
129121const char * const root_certs[] = {
Original file line number Diff line number Diff line change 4141namespace node {
4242namespace crypto {
4343
44+ // Forcibly clear OpenSSL's error stack on return. This stops stale errors
45+ // from popping up later in the lifecycle of crypto operations where they
46+ // would cause spurious failures. It's a rather blunt method, though.
47+ // ERR_clear_error() isn't necessarily cheap either.
48+ struct ClearErrorOnReturn {
49+ ~ClearErrorOnReturn () { ERR_clear_error (); }
50+ };
51+
52+ // Pop errors from OpenSSL's error stack that were added
53+ // between when this was constructed and destructed.
54+ struct MarkPopErrorOnReturn {
55+ MarkPopErrorOnReturn () { ERR_set_mark (); }
56+ ~MarkPopErrorOnReturn () { ERR_pop_to_mark (); }
57+ };
58+
4459enum CheckResult {
4560 CHECK_CERT_REVOKED = 0 ,
4661 CHECK_OK = 1
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ using v8::Object;
3131using v8::String;
3232using v8::Value;
3333
34-
3534TLSWrap::TLSWrap (Environment* env,
3635 Kind kind,
3736 StreamBase* stream,
@@ -401,6 +400,8 @@ void TLSWrap::ClearOut() {
401400 if (ssl_ == nullptr )
402401 return ;
403402
403+ crypto::MarkPopErrorOnReturn mark_pop_error_on_return;
404+
404405 char out[kClearOutChunkSize ];
405406 int read;
406407 for (;;) {
@@ -462,6 +463,8 @@ bool TLSWrap::ClearIn() {
462463 if (ssl_ == nullptr )
463464 return false ;
464465
466+ crypto::MarkPopErrorOnReturn mark_pop_error_on_return;
467+
465468 int written = 0 ;
466469 while (clear_in_->Length () > 0 ) {
467470 size_t avail = 0 ;
@@ -589,6 +592,8 @@ int TLSWrap::DoWrite(WriteWrap* w,
589592 if (ssl_ == nullptr )
590593 return UV_EPROTO;
591594
595+ crypto::MarkPopErrorOnReturn mark_pop_error_on_return;
596+
592597 int written = 0 ;
593598 for (i = 0 ; i < count; i++) {
594599 written = SSL_write (ssl_, bufs[i].base , bufs[i].len );
@@ -704,8 +709,11 @@ void TLSWrap::DoRead(ssize_t nread,
704709
705710
706711int TLSWrap::DoShutdown (ShutdownWrap* req_wrap) {
712+ crypto::MarkPopErrorOnReturn mark_pop_error_on_return;
713+
707714 if (ssl_ != nullptr && SSL_shutdown (ssl_) == 0 )
708715 SSL_shutdown (ssl_);
716+
709717 shutdown_ = true ;
710718 EncOut ();
711719 return stream_->DoShutdown (req_wrap);
You can’t perform that action at this time.
0 commit comments