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

How to run a test server #2

Open
tomato42 opened this issue Dec 4, 2015 · 4 comments
Open

How to run a test server #2

tomato42 opened this issue Dec 4, 2015 · 4 comments

Comments

@tomato42
Copy link

tomato42 commented Dec 4, 2015

I want to run a set of tests against the miTLS implementation. For that I want a server that stays up and handles all connections as they come.

When I use ./FlexApps.exe -s fh --accept 127.0.0.1:4433 --server-cert mitls the server closes as soon as a single client finishes communication.
Moreover, connecting to it while advertising support for just the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite causes it to crash:

--- TCP : Listening on 127.0.0.1:4433
--- TCP : Accepting as rsa.cert-02.mitls.org
--- --- Client accepted
--- # CLIENT HELLO : FlexClientHello.receive
--- --- Protocol Version : TLS_1p2
--- --- Sid : 
--- --- Client Random : 0000000000000000000000000000000000000000000000000000000000000000
--- --- Ciphersuites : [TLS_RSA_WITH_AES_128_CBC_SHA]
--- --- Compressions : [NullCompression]
--- --- Extensions : [TLSExtensions+clientExtension+CE_server_name;
 TLSExtensions+clientExtension+CE_renegotiation_info]
--- --- Payload : 03030000000000000000000000000000000000000000000000000000000000000000000002002F01000023FF010001000000001A00180000157273612E636572742D30312E6D69746C732E6F7267

Unhandled Exception:
System.Exception: Error at Handshake_full_RSA.fs:159: No suitable ciphersuite given.
  at FlexApps.Handshake_full_RSA+Handshake_full_RSA.server (System.String listening_address, Microsoft.FSharp.Collections.FSharpList`1 chain, sk sk, Microsoft.FSharp.Core.FSharpOption`1 port, Microsoft.FSharp.Core.FSharpOption`1 timeout) <0x40de3190 + 0x00327> in <filename unknown>:0 
  at FlexApps.Handshake_full_RSA+Handshake_full_RSA.server (System.String listening_address, Microsoft.FSharp.Core.FSharpOption`1 cn_hint, Microsoft.FSharp.Core.FSharpOption`1 port, Microsoft.FSharp.Core.FSharpOption`1 timeout) <0x40d914c0 + 0x00167> in <filename unknown>:0 
  at FlexApps.Application.runRelease$cont@67-1 (FlexApps.CommandLineOpts opts, Microsoft.FSharp.Core.Unit unitVar) <0x40d90ab0 + 0x003c7> in <filename unknown>:0 
  at FlexApps.Application.runRelease$cont@63 (Microsoft.FSharp.Core.FSharpOption`1 matchValue, Microsoft.FSharp.Core.Unit unitVar) <0x40d90360 + 0x0007b> in <filename unknown>:0 
  at FlexApps.Application.runRelease (IEnumerable`1 argv) <0x40d4a210 + 0x00053> in <filename unknown>:0 
  at FlexApps.Application.main (System.String[] argv) <0x40d49e00 + 0x00023> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Error at Handshake_full_RSA.fs:159: No suitable ciphersuite given.
  at FlexApps.Handshake_full_RSA+Handshake_full_RSA.server (System.String listening_address, Microsoft.FSharp.Collections.FSharpList`1 chain, sk sk, Microsoft.FSharp.Core.FSharpOption`1 port, Microsoft.FSharp.Core.FSharpOption`1 timeout) <0x40de3190 + 0x00327> in <filename unknown>:0 
  at FlexApps.Handshake_full_RSA+Handshake_full_RSA.server (System.String listening_address, Microsoft.FSharp.Core.FSharpOption`1 cn_hint, Microsoft.FSharp.Core.FSharpOption`1 port, Microsoft.FSharp.Core.FSharpOption`1 timeout) <0x40d914c0 + 0x00167> in <filename unknown>:0 
  at FlexApps.Application.runRelease$cont@67-1 (FlexApps.CommandLineOpts opts, Microsoft.FSharp.Core.Unit unitVar) <0x40d90ab0 + 0x003c7> in <filename unknown>:0 
  at FlexApps.Application.runRelease$cont@63 (Microsoft.FSharp.Core.FSharpOption`1 matchValue, Microsoft.FSharp.Core.Unit unitVar) <0x40d90360 + 0x0007b> in <filename unknown>:0 
  at FlexApps.Application.runRelease (IEnumerable`1 argv) <0x40d4a210 + 0x00053> in <filename unknown>:0 
  at FlexApps.Application.main (System.String[] argv) <0x40d49e00 + 0x00023> in <filename unknown>:0

When I tried to start the echo and HttpServer they complained about missing certificate:

System.IO.IOException: TLS-HS: Sent fatal alert: AD_internal_error "Error at Handshake.fs:1275: Could not find in the store a certificate for the negotiated ciphersuite."
  at TLStream+TLStream.doHS (preConnection conn) <0x41edadf0 + 0x0022b> in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) TLStream+TLStream:doHS (Dispatch/preConnection)
  at TLStream+TLStream..ctor (System.IO.Stream s, config options, TLSBehavior b, Microsoft.FSharp.Core.FSharpOption`1 own, Microsoft.FSharp.Core.FSharpOption`1 sessionID, Microsoft.FSharp.Core.FSharpOption`1 certQuery) <0x41ed3c20 + 0x0037f> in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) TLStream+TLStream:.ctor (System.IO.Stream,TLSInfo/config,TLStream/TLSBehavior,Microsoft.FSharp.Core.FSharpOption`1<bool>,Microsoft.FSharp.Core.FSharpOption`1<Bytes/bytes>,Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Collections.FSharpList`1<Bytes/bytes>, Microsoft.FSharp.Core.FSharpFunc`2<bool, bool>>>)
  at EchoImpl.client_handler (config ctxt, System.Net.Sockets.Socket peer, Boolean insecure, Microsoft.FSharp.Core.Unit unitVar0) <0x41ecb560 + 0x00323> in <filename unknown>:0 
Disconnect: 127.0.0.1:40280

and, for HttpServer:

TLS-HS: Sent fatal alert: AD_internal_error "Error at Handshake.fs:1275: Could not find in the store a certificate for the negotiated ciphersuite."

So, how can I start a server that stays up and supports all the ciphers miTLS supports?

@ad-l
Copy link

ad-l commented Dec 4, 2015

HttpServer is your best bet for a full server that stays up.
To use httpServer you should give it the --local-name option with the Common Name of a TLS certificate in your store (Windows or Mozilla on mono). For instance, try running:

HttpServer.exe --local-name rsa.cert-02.mitls.org

@ad-l
Copy link

ad-l commented Dec 4, 2015

Also, if you would like to use your own certificate and you are on mono, it should be added to the certificate store using the certmgr tool.

@beurdouche
Copy link
Member

As Antoine says, if your goal really is to test miTLS, you should not use FlexTLS as it is design to break the security properties of miTLS using the low level modules instead of the verified state machine.

Just in case you are interested to know what happens with the FlexTLS failure :
https://github.com/mitls/mitls-flex/blob/master/flex/FlexApps/Handshake_full_RSA.fs#L158
Here you can see that the scenario you run will enforce a single ciphersuite (TLS_RSA_WITH_AES_128_GCM_SHA256), of course you can create a scenario enforcing whatever you prefer.

miTLS supported ciphersuites are listed here :
https://github.com/mitls/mitls-flex/blob/master/src/tls/TLSConstants.fs#L720

@tomato42
Copy link
Author

tomato42 commented Dec 4, 2015

Also, if you would like to use your own certificate and you are on mono, it should be added to the
certificate store using the certmgr tool.

I've already done that for the FlexApps tool, and didn't have to configure it there, so I assumed that HttpServer will default to the same one; help message not mentioning certificates in the context of --local-name didn't help either. I also did try to connect with the SNI of the certificate I did install and it still was failing...

Just in case you are interested to know what happens with the FlexTLS failure :
Here you can see that the scenario you run will enforce a single ciphersuite
(TLS_RSA_WITH_AES_128_GCM_SHA256),

Curious choice, given that TLS_RSA_WITH_AES_128_CBC_SHA is the mandatory to implement one from RFC 5246.

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

No branches or pull requests

3 participants