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

fix bug in node_crypto.cc#4262

Closed
fat-crocodile wants to merge 2 commits intonodejs:masterfrom
fat-crocodile:master
Closed

fix bug in node_crypto.cc#4262
fat-crocodile wants to merge 2 commits intonodejs:masterfrom
fat-crocodile:master

Conversation

@fat-crocodile
Copy link

Fixed problem:

  1. OpenSSL contains errors in thread-specific errors stacks. Becouse of asynchronous nature of nodejs, all nodejs connections share the same errors stack. So, if you didn't process error (and clean stack) in one connection, you will surprisingly get it in another one.

  2. Function SSL_get_error can not work correctly if before apropriate SSL/TLS call errors stack was not empty (see http://openssl.org/docs/ssl/SSL_get_error.html )

  3. Your version of HandleSSLError always interpret zero as a non-error code. For SSL_accept, SSL_connect and SS_write it is not true (see http://openssl.org/docs/ssl/SSL_connect.html ). Apropriate errors were never processed and another connection got them.

  4. And see comment about SSL_shutdown in my code.

…it does not mean an error, but sometimes it does
@indutny
Copy link
Member

indutny commented Nov 9, 2012

Omg, this is so awesome. lgtm

@fat-crocodile
Copy link
Author

I hope, you say "awesome" not about my English :)

@englercj
Copy link

englercj commented Nov 9, 2012

Nice work!

Copy link
Member

Choose a reason for hiding this comment

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

I really do not like default arguments, it complicates code and doesn't fit C++ style used by node...

Can I ask you to use enum for this?

Copy link
Author

Choose a reason for hiding this comment

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

Define special enum with two values to use it in only one sitaution... Looks redundand for me.
May be just bool, without default argument?

Copy link
Member

Choose a reason for hiding this comment

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

I second @indutny's suggestion. An enum at the call site is much more descriptive for readers of the code than a boolean is.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, that's why I asked you :)

@indutny
Copy link
Member

indutny commented Nov 16, 2012

Also, can you please sign CLA ?

@fat-crocodile
Copy link
Author

Check new commit.

I removed bidirectional shutdown as you ask. But top-level code can't help with it -- it will never know that something goes wrong.

And I made HandleSSLError calls more clear.

I am not competent in your code style, so may be it is still not good enought. It will be ok for me, if you will reject my pull request and fix this bug yourself. I am vain a little, but I'll stand :)

I signed CLA.

@bnoordhuis
Copy link
Member

LGTM. @indutny?

@indutny
Copy link
Member

indutny commented Nov 16, 2012

Yes, LGTM! :) Thanks.

Can someone please open a bug about "not-graceful" ssl shutdown? I'm too lame to do it :)

@bnoordhuis
Copy link
Member

Thanks Sergey, landed in 019ad34.

@bnoordhuis bnoordhuis closed this Nov 16, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants