Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

tls: show human-readable error messages #6897

Closed

Conversation

bnoordhuis
Copy link
Member

Before this commit, verification exceptions had err.message set to the
OpenSSL error code (e.g. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE').

This commit moves the error code to err.code and replaces err.message
with a human-readable error. Example:

// before
{
  message: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}

// after
{
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  message: 'unable to verify the first certificate'
}

UNABLE_TO_VERIFY_LEAF_SIGNATURE is a good example of why you want this:
the error code suggests that it's the last certificate that fails to
validate while it's actually the first certificate in the chain.

Going by the number of mailing list posts and StackOverflow questions,
it's a source of confusion to many people.

Suggested reviewer: @indutny

Before this commit, verification exceptions had err.message set to the
OpenSSL error code (e.g. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE').

This commit moves the error code to err.code and replaces err.message
with a human-readable error.  Example:

    // before
    {
      message: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    }

    // after
    {
      code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
      message: 'unable to verify the first certificate'
    }

UNABLE_TO_VERIFY_LEAF_SIGNATURE is a good example of why you want this:
the error code suggests that it's the last certificate that fails to
validate while it's actually the first certificate in the chain.

Going by the number of mailing list posts and StackOverflow questions,
it's a source of confusion to many people.
template <class Base>
void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks a bit unrelated, right? Mind opening issue for changing all HandleScopes in this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's related in the sense that we need the isolate further down below. I thought I'd fix up the HandleScope while I'm here, saves work if/when node grows multi-isolate support. I can back it out if you want.

I'm not going to fix up all the HandleScopes in the file however, I'm strictly working on a scratch-my-own-itch basis. (Or scratch-a-user-itch as is the case here.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you got me wrong, I'm going to fix it myself. Just would be cool if this patch won't contain partial fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, 'opening issue' - yes, I misread that. :-) Will do and I'll back out this change.

@indutny
Copy link
Member

indutny commented Jan 17, 2014

Few very minor nits, otherwise LGTM! Thank you!

@bnoordhuis
Copy link
Member Author

Fix-ups in eef298f. See #6899 for the isolate story.

@indutny
Copy link
Member

indutny commented Jan 17, 2014

Thank you very much! Landed in 262a752

@indutny indutny closed this Jan 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants