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: fix bugs of double TLS #48796

Closed
wants to merge 4 commits into from

Commits on Jul 16, 2023

  1. tls: fix bugs of double TLS

    Fixs two issues in `TLSWrap`, one of them is reported in
    nodejs#30896.
    
    1. `TLSWrap` has exactly one `StreamListener`, however,
    that `StreamListener` can be replaced. We have not been
    rigorous enough here: if an active write has not been
    finished before the transition, the finish callback of it
    will be wrongly fired the successor `StreamListener`.
    
    2. A `TLSWrap` does not allow more than one active write,
    as checked in the assertion about current_write in
    `TLSWrap::DoWrite()`.
    
    However, when users make use of an existing `tls.TLSSocket`
    to establish double TLS, by
    either
      tls.connect({socket: tlssock})
    or
      tlsServer.emit('connection', tlssock)
    we have both of the user provided `tls.TLSSocket`, tlssock and
    a brand new created `TLSWrap` writing to the `TLSWrap` bound to
    tlssock, which easily violates the constranint because two writers
    have no idea of each other.
    
    The design of the fix is:
    when a `TLSWrap` is created on top of a user provided socket,
    do not send any data to the socket until all existing writes
    of the socket are done and ensure registered callbacks of
    those writes can be fired.
    ywave620 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    63c8fb0 View commit details
    Browse the repository at this point in the history
  2. tls: fix bugs of double TLS

    Format code.
    ywave620 committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    7e2ec19 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2023

  1. tls: fix bugs of double TLS

    Remove unnecessary saving of `this` for arrow function.
    ywave620 committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    8ce31c6 View commit details
    Browse the repository at this point in the history
  2. tls: fix bugs of double TLS

    Fix typo
    ywave620 committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    29aade9 View commit details
    Browse the repository at this point in the history