@@ -733,19 +733,14 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
733
733
734
734
if (!key) {
735
735
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" );
740
737
}
741
738
742
739
int rv = SSL_CTX_use_PrivateKey (sc->ctx_ .get (), key.get ());
743
740
744
741
if (!rv) {
745
742
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" );
749
744
}
750
745
}
751
746
@@ -971,10 +966,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
971
966
972
967
if (!rv) {
973
968
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" );
978
970
}
979
971
}
980
972
@@ -1183,11 +1175,7 @@ void SecureContext::SetCipherSuites(const FunctionCallbackInfo<Value>& args) {
1183
1175
const node::Utf8Value ciphers (args.GetIsolate (), args[0 ]);
1184
1176
if (!SSL_CTX_set_ciphersuites (sc->ctx_ .get (), *ciphers)) {
1185
1177
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" );
1191
1179
}
1192
1180
#endif
1193
1181
}
@@ -1205,10 +1193,6 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
1205
1193
const node::Utf8Value ciphers (args.GetIsolate (), args[0 ]);
1206
1194
if (!SSL_CTX_set_cipher_list (sc->ctx_ .get (), *ciphers)) {
1207
1195
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
- }
1212
1196
1213
1197
if (strlen (*ciphers) == 0 && ERR_GET_REASON (err) == SSL_R_NO_CIPHER_MATCH) {
1214
1198
// TLS1.2 ciphers were deliberately cleared, so don't consider
@@ -1217,7 +1201,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
1217
1201
// that's actually an error.
1218
1202
return ;
1219
1203
}
1220
- return ThrowCryptoError (env, err);
1204
+ return ThrowCryptoError (env, err, " Failed to set ciphers " );
1221
1205
}
1222
1206
}
1223
1207
@@ -3029,9 +3013,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
3029
3013
// Not clear why sometimes we throw error, and sometimes we call
3030
3014
// onerror(). Both cause .destroy(), but onerror does a bit more.
3031
3015
unsigned long err = ERR_get_error (); // NOLINT(runtime/int)
3032
- if (!err)
3033
- return env->ThrowError (" CertCbDone" );
3034
- return ThrowCryptoError (env, err);
3016
+ return ThrowCryptoError (env, err, " CertCbDone" );
3035
3017
}
3036
3018
} else {
3037
3019
// Failure: incorrect SNI context object
0 commit comments