Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls: change TLSWrap::GetProtocol to fix #56935 #57036

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nathanjjohnson7
Copy link

tls: change tlsSocket.getProtocol() to return null for server sockets

I updated TLSWrap::GetProtocol to return null for server sockets.
I updated a test to ensure that the returned protocol is indeed null for
server sockets.

Fixes: #56935

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
-->

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.12%. Comparing base (85f5a6c) to head (12ef396).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57036      +/-   ##
==========================================
+ Coverage   89.11%   89.12%   +0.01%     
==========================================
  Files         665      665              
  Lines      193193   193206      +13     
  Branches    37212    37220       +8     
==========================================
+ Hits       172158   172194      +36     
+ Misses      13775    13757      -18     
+ Partials     7260     7255       -5     
Files with missing lines Coverage Δ
src/crypto/crypto_tls.cc 78.21% <100.00%> (+0.04%) ⬆️

... and 29 files with indirect coverage changes

@nathanjjohnson7 nathanjjohnson7 force-pushed the fix-tlsSocket-getProtocol-branch branch from 872fcf5 to 12ef396 Compare February 13, 2025 20:23
args.GetReturnValue().SetNull();
return;
}

args.GetReturnValue().Set(
OneByteString(env->isolate(), SSL_get_version(w->ssl_.get())));
Copy link
Member

Choose a reason for hiding this comment

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

Is the return value of SSL_get_version() incorrect or misleading? If not, wouldn't we want to adjust the documentation instead of the code?

Copy link
Author

Choose a reason for hiding this comment

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

On further inspection, I think you're right. It should probably just be a documentation change. That being said, if you look at the first code snippet shared in #56935, getProtocol() is returning TLSv1.3 for an unconnected server socket. Shouldn't it be returning null as long as a tls handshake has not been completed, or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tlsSocket.getProtocol() does not return null for server sockets
3 participants