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

Restore ability to renegotiate #164

Merged
merged 2 commits into from
Mar 1, 2017
Merged

Restore ability to renegotiate #164

merged 2 commits into from
Mar 1, 2017

Conversation

ocheron
Copy link
Contributor

@ocheron ocheron commented Oct 3, 2016

This is a fix for #161.

The handshake behaviour is slightly modified because the implementation will now accept to start a second handshake replacing a first handshake that is not finished yet. I don’t think this can cause any harm, especially with secure renegotiations. But if required it should also be possible to use more complex logic or add new state to discriminate between finished and on-going handshake cases.

@ocheron
Copy link
Contributor Author

ocheron commented Oct 3, 2016

The test suite contains renegotiation tests but does not demonstrate the bug because tls renegotiates with itself. I tested manually against OpenSSL like this:

Server-initiated renegotiation

  • [Terminal 1] Start OpenSSL server:

    $ openssl req -x509 -subj /CN=localhost -new -nodes -out cert.pem
    $ openssl s_server -key privkey.pem -cert cert.pem
  • [Terminal 2] Start tls-simpleclient:

    $ tls-simpleclient --http1.1 --no-validation -t 60000 localhost 4433 -d
  • [Terminal 1] Press r + <Return> to trigger renegotiation in s_server

Client-initiated renegotiation

  • [Terminal 1] Start tls-simpleserver with new option --allow-renegotiation (added in commit ocheron/hs-tls@76f87cc):

    $ tls-simpleserver --key privkey.pem --certificate cert.pem -t 60000 \
      --allow-renegotiation 4433
  • [Terminal 2] Start OpenSSL client:

    $ openssl s_client
  • [Terminal 2] Press R + <Return> to trigger renegotiation in s_client

Copy link
Collaborator

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.
Looks great to me!

@kazu-yamamoto
Copy link
Collaborator

@ocheron Do you want to merge this PR by yourself?

@ocheron
Copy link
Contributor Author

ocheron commented Feb 28, 2017

OK I'll merge it, but first I'll also take some time to remember what was the possible improvement and create an issue to track it.

Function handshakeTerminate does not clear ctxHandshake anymore, so the next
call to startHandshake must reset it.
@ocheron ocheron merged commit e26e837 into haskell-tls:master Mar 1, 2017
@ocheron ocheron deleted the renegotiation-fixes branch March 1, 2017 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants