Permalink
Browse files

crypto: fix error reporting in SetKey()

  • Loading branch information...
1 parent fce7c95 commit 58433a2fdec234cf98caf0f9a8049b7390ef7bc4 @indutny committed Jun 21, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/node_crypto.cc
View
@@ -297,7 +297,14 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) {
if (!key) {
BIO_free(bio);
- return False();
+ unsigned long err = ERR_get_error();
+ if (!err) {
+ return ThrowException(Exception::Error(
+ String::New("PEM_read_bio_PrivateKey")));
+ }
+ char string[120];
+ ERR_error_string_n(err, string, sizeof string);
+ return ThrowException(Exception::Error(String::New(string)));
}
SSL_CTX_use_PrivateKey(sc->ctx_, key);

0 comments on commit 58433a2

Please sign in to comment.