Skip to content

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

@kazu-yamamoto kazu-yamamoto self-requested a review February 27, 2017 03:05
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.

ocheron added 2 commits March 1, 2017 19:01
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.

2 participants