@@ -733,19 +733,14 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
733733
734734 if (!key) {
735735 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
736- if (!err) {
737- return env->ThrowError (" PEM_read_bio_PrivateKey" );
738- }
739- return ThrowCryptoError (env, err);
736+ return ThrowCryptoError (env, err, " PEM_read_bio_PrivateKey" );
740737 }
741738
742739 int rv = SSL_CTX_use_PrivateKey (sc->ctx_ .get (), key.get ());
743740
744741 if (!rv) {
745742 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
746- if (!err)
747- return env->ThrowError (" SSL_CTX_use_PrivateKey" );
748- return ThrowCryptoError (env, err);
743+ return ThrowCryptoError (env, err, " SSL_CTX_use_PrivateKey" );
749744 }
750745}
751746
@@ -971,10 +966,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
971966
972967 if (!rv) {
973968 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
974- if (!err) {
975- return env->ThrowError (" SSL_CTX_use_certificate_chain" );
976- }
977- return ThrowCryptoError (env, err);
969+ return ThrowCryptoError (env, err, " SSL_CTX_use_certificate_chain" );
978970 }
979971}
980972
@@ -1183,11 +1175,7 @@ void SecureContext::SetCipherSuites(const FunctionCallbackInfo<Value>& args) {
11831175 const node::Utf8Value ciphers (args.GetIsolate (), args[0 ]);
11841176 if (!SSL_CTX_set_ciphersuites (sc->ctx_ .get (), *ciphers)) {
11851177 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
1186- if (!err) {
1187- // This would be an OpenSSL bug if it happened.
1188- return env->ThrowError (" Failed to set ciphers" );
1189- }
1190- return ThrowCryptoError (env, err);
1178+ return ThrowCryptoError (env, err, " Failed to set ciphers" );
11911179 }
11921180#endif
11931181}
@@ -1205,10 +1193,6 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
12051193 const node::Utf8Value ciphers (args.GetIsolate (), args[0 ]);
12061194 if (!SSL_CTX_set_cipher_list (sc->ctx_ .get (), *ciphers)) {
12071195 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
1208- if (!err) {
1209- // This would be an OpenSSL bug if it happened.
1210- return env->ThrowError (" Failed to set ciphers" );
1211- }
12121196
12131197 if (strlen (*ciphers) == 0 && ERR_GET_REASON (err) == SSL_R_NO_CIPHER_MATCH) {
12141198 // TLS1.2 ciphers were deliberately cleared, so don't consider
@@ -1217,7 +1201,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
12171201 // that's actually an error.
12181202 return ;
12191203 }
1220- return ThrowCryptoError (env, err);
1204+ return ThrowCryptoError (env, err, " Failed to set ciphers " );
12211205 }
12221206}
12231207
@@ -3030,9 +3014,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
30303014 // Not clear why sometimes we throw error, and sometimes we call
30313015 // onerror(). Both cause .destroy(), but onerror does a bit more.
30323016 unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
3033- if (!err)
3034- return env->ThrowError (" CertCbDone" );
3035- return ThrowCryptoError (env, err);
3017+ return ThrowCryptoError (env, err, " CertCbDone" );
30363018 }
30373019 } else {
30383020 // Failure: incorrect SNI context object
0 commit comments