{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/418","repository_url":"https://api.github.com/repos/ARMmbed/mbedtls","labels_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/418/comments","events_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/418/events","html_url":"https://github.com/ARMmbed/mbedtls/issues/418","id":131128659,"number":418,"title":"Error in ssl_pthread_server example and/or mbedtls_net_accept library","user":{"login":"faroutliving","id":17052248,"avatar_url":"https://avatars.githubusercontent.com/u/17052248?v=3","gravatar_id":"","url":"https://api.github.com/users/faroutliving","html_url":"https://github.com/faroutliving","followers_url":"https://api.github.com/users/faroutliving/followers","following_url":"https://api.github.com/users/faroutliving/following{/other_user}","gists_url":"https://api.github.com/users/faroutliving/gists{/gist_id}","starred_url":"https://api.github.com/users/faroutliving/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faroutliving/subscriptions","organizations_url":"https://api.github.com/users/faroutliving/orgs","repos_url":"https://api.github.com/users/faroutliving/repos","events_url":"https://api.github.com/users/faroutliving/events{/privacy}","received_events_url":"https://api.github.com/users/faroutliving/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ARMmbed/mbedtls/labels/mirrored","name":"mirrored","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-03T19:30:23Z","updated_at":"2016-02-04T07:26:58Z","closed_at":null,"body":"I modeled my simple client after the example ssl_pthread_server but noticed some strange behavior. Each connection that comes in causes mbedtls_net_accept to return twice for that connection. One will eventually fail to read data, but it still causes two complete runs through the thread creation, ssl setup, ssl handshake etc.\r\n\r\nSo I went and ran the ssl_pthread_server example as built by mbedtls-2.2.1 and it exhibited the exact same behavior. Output from ssl_pthread_server shown below.\r\n\r\nI've tried the forums and direct email and have heard nothing back.\r\n\r\nDeron\r\n\r\n./ssl_pthread_server\r\n```\r\n. Loading the server cert. and key... ok\r\n. Seeding the random number generator... ok\r\n. Setting up the SSL data.... ok\r\n. Bind on https://localhost:4433/ ... ok\r\n[ main ] Waiting for a remote connection\r\n[ main ] ok\r\n[ main ] Creating a new thread\r\n[ main ] Waiting for a remote connection\r\n[ main ] ok\r\n[ main ] Creating a new thread\r\n[ main ] Waiting for a remote connection\r\n[ #139733925684992 ] Setting up SSL/TLS data\r\n[ #139733917292288 ] Setting up SSL/TLS data\r\n[ #139733925684992 ] Performing the SSL/TLS handshake\r\n[ #139733917292288 ] Performing the SSL/TLS handshake\r\n[ #139733925684992 ] ok\r\n[ #139733925684992 ] < Read from client\r\n[ #139733917292288 ] ok\r\n[ #139733917292288 ] < Read from client\r\n[ #139733925684992 ] 323 bytes read\r\n=====\r\nGET / HTTP/1.1\r\nHost: mydomain.com:4433\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\n\r\n=====\r\n[ #139733925684992 ] > Write to client:\r\n[ #139733925684992 ] 147 bytes written\r\n=====\r\nHTTP/1.0 200 OK\r\nContent-Type: text/html\r\nmbed TLS Test Server\r\n\r\nSuccessful connection using: TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA\r\n\r\n=====\r\n[ #139733925684992 ] . Closing the connection... ok\r\n[ #139733917292288 ] connection was closed gracefully\r\n[ #139733917292288 ] Last error was: -0x7880 - SSL - The peer notified us that the connection is going to be closed\r\n```"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/comments/179687390","html_url":"https://github.com/ARMmbed/mbedtls/issues/418#issuecomment-179687390","issue_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/418","id":179687390,"user":{"login":"pieceofsummer","id":2262364,"avatar_url":"https://avatars.githubusercontent.com/u/2262364?v=3","gravatar_id":"","url":"https://api.github.com/users/pieceofsummer","html_url":"https://github.com/pieceofsummer","followers_url":"https://api.github.com/users/pieceofsummer/followers","following_url":"https://api.github.com/users/pieceofsummer/following{/other_user}","gists_url":"https://api.github.com/users/pieceofsummer/gists{/gist_id}","starred_url":"https://api.github.com/users/pieceofsummer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pieceofsummer/subscriptions","organizations_url":"https://api.github.com/users/pieceofsummer/orgs","repos_url":"https://api.github.com/users/pieceofsummer/repos","events_url":"https://api.github.com/users/pieceofsummer/events{/privacy}","received_events_url":"https://api.github.com/users/pieceofsummer/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T07:26:58Z","updated_at":"2016-02-04T07:26:58Z","body":"Seems more like your client issue to me. Requesting with curl yields only one connection:\r\n\r\n```\r\nMacBook-Air:~$ curl -k https://localhost:4433/\r\n<h2>mbed TLS Test Server</h2>\r\n<p>Successful connection using: TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384</p>\r\n```\r\n\r\n```\r\nMacBook-Air:mbedtls$ ./programs/ssl/ssl_pthread_server\r\n\r\n  . Loading the server cert. and key... ok\r\n  . Seeding the random number generator... ok\r\n  . Setting up the SSL data.... ok\r\n  . Bind on https://localhost:4433/ ... ok\r\n  [ main ]  Waiting for a remote connection\r\n  [ main ]  ok\r\n  [ main ]  Creating a new thread\r\n  [ main ]  Waiting for a remote connection\r\n  [ #123145302839296 ]  Setting up SSL/TLS data\r\n  [ #123145302839296 ]  Performing the SSL/TLS handshake\r\n  [ #123145302839296 ]  ok\r\n  [ #123145302839296 ]  < Read from client\r\n  [ #123145302839296 ]  78 bytes read\r\n=====\r\nGET / HTTP/1.1\r\nHost: localhost:4433\r\nUser-Agent: curl/7.43.0\r\nAccept: */*\r\n\r\n\r\n=====\r\n  [ #123145302839296 ]  > Write to client:\r\n  [ #123145302839296 ]  150 bytes written\r\n=====\r\nHTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h2>mbed TLS Test Server</h2>\r\n<p>Successful connection using: TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384</p>\r\n\r\n=====\r\n  [ #123145302839296 ]  . Closing the connection... ok\r\n```"}}