{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/51","repository_url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl","labels_url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/51/comments","events_url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/51/events","html_url":"https://github.com/JuliaWeb/WebSockets.jl/issues/51","id":135261790,"number":51,"title":"HTTPS SSL TLS Using websockets doesnt work","user":{"login":"dioptre","id":760216,"avatar_url":"https://avatars.githubusercontent.com/u/760216?v=3","gravatar_id":"","url":"https://api.github.com/users/dioptre","html_url":"https://github.com/dioptre","followers_url":"https://api.github.com/users/dioptre/followers","following_url":"https://api.github.com/users/dioptre/following{/other_user}","gists_url":"https://api.github.com/users/dioptre/gists{/gist_id}","starred_url":"https://api.github.com/users/dioptre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dioptre/subscriptions","organizations_url":"https://api.github.com/users/dioptre/orgs","repos_url":"https://api.github.com/users/dioptre/repos","events_url":"https://api.github.com/users/dioptre/events{/privacy}","received_events_url":"https://api.github.com/users/dioptre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-21T21:24:04Z","updated_at":"2016-05-01T11:11:50Z","closed_at":null,"body":"Line 381 in Websocket.jl:\r\n\r\n>  sock = WebSocket(client.id, client.sock)\r\n\r\nReceives a MbedTLS SSLContext in the client.sock value as per HttpServer.jl:\r\n\r\n```\r\n     sess = MbedTLS.SSLContext()\r\n        MbedTLS.setup!(sess, ssl_config)\r\n        # set_priority_string!(sess)\r\n        # set_credentials!(sess, cert_store)\r\n        client = accept(server.http.sock)\r\n        try\r\n            MbedTLS.set_bio!(sess, client)\r\n            MbedTLS.handshake(sess)\r\n            # associate_stream(sess, client)\r\n            # handshake!(sess)\r\n        catch e\r\n            println(\"Error establishing SSL connection: \", e)\r\n            close(client)\r\n            continue\r\n        end\r\n        client = Client(id_pool += 1, sess)\r\n        client.parser = ClientParser(message_handler(server, client, websockets_enabled))\r\n        @async process_client(server, client, websockets_enabled)`\r\n```\r\nhttps://github.com/JuliaWeb/HttpServer.jl/issues/87\r\nAs I'm not sure which project is better to help massage the socket into, I'm looking for help on this one. Please let me know what to do! Thanks\r\n\r\nPS Here's more interesting debug info:\r\n\r\n> HttpServer.Client{MbedTLS.SSLContext}(14,MbedTLS.SSLContext(Ptr{Void} @0x0000000003245910,MbedTLS.SSLConfig(Ptr{Void} @0x0000000002dff880,MbedTLS.CtrDrbg(Ptr{Void} @0x0000000002ca2f00,Nullable(MbedTLS.Entropy(Ptr{Void} @0x0000000002e54c90,Any[]))),#undef,(anonymous function),cert. version     : 3\r\n> serial number     : DB:7E:D8:55:3E:F1:AB:AC\r\n> issuer name       : C=US, ST=CA, L=San Francisco, O=BXI, CN=bxi.io, emailAddress=dioptre@gmail.com\r\n> subject name      : C=US, ST=CA, L=San Francisco, O=BXI, CN=bxi.io, emailAddress=dioptre@gmail.com\r\n> issued  on        : 2016-02-21 07:47:43\r\n> expires on        : 2017-02-20 07:47:43\r\n> signed using      : RSA with SHA-256\r\n> RSA key size      : 2048 bits\r\n> basic constraints : CA=true\r\n> ,MbedTLS.PKContext(Ptr{Void} @0x0000000002cf1160)),true,TCPSocket(open, 0 bytes waiting)),HttpServer.ClientParser(HttpParser,HttpParser.ParserSettings(Ptr{Void} @0x00007fcb39e9ffc0,Ptr{Void} @0x00007fcb39ea35d0,Ptr{Void} @0x00007fcb39ea3810,Ptr{Void} @0x00007fcb39ea3850,Ptr{Void} @0x00007fcb39ea3a80,Ptr{Void} @0x00007fcb39ea4c80,Ptr{Void} @0x00007fcb39ea50a0,Ptr{Void} @0x00007fcb39ea5210)))WARNING: both Patchwork and Base export \"Text\"; uses of it in module Main must be qualified\r\n> ERROR (unhandled task failure): MethodError: `convert` has no method matching convert(::Type{TCPSocket}, ::MbedTLS.SSLContext)\r\n> This may have arisen from a call to the constructor TCPSocket(...),\r\n> since type constructors fall back to convert methods.\r\n> Closest candidates are:\r\n>   TCPSocket(::Any)\r\n>   call{T}(::Type{T}, ::Any)\r\n>   convert{T}(::Type{T}, ::T)\r\n>   ...\r\n>  in call at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:57\r\n>  in handle at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:387\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/HttpServer.jl:393\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/RequestParser.jl:104\r\n> \r\n\r\nPPS This is what I tried (using client.sock.bio):\r\nhttps://github.com/dioptre/WebSockets.jl/commit/3bb92d7b09cfc19ff392edd8bb11d3b3e6e99cbf\r\n\r\n...and new error\r\n\r\n> handling websocket connection:\r\n> write: broken pipe (EPIPE)\r\n>  in yieldto at ./task.jl:71\r\n>  in wait at ./task.jl:371\r\n>  in stream_wait at ./stream.jl:60\r\n>  in uv_write at stream.jl:944\r\n>  in flush at stream.jl:979\r\n>  in locked_write at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:154\r\n>  in write at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:168\r\n>  in start_updates at /home/a/projects/bxi/server/www.jl:213\r\n>  in anonymous at /home/a/projects/bxi/server/www.jl:274\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:15\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:8\r\n>  in splitquery at /home/a/.julia/v0.4/Mux/src/basics.jl:28\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:8\r\n>  in wcatch at /home/a/.julia/v0.4/Mux/src/websockets_integration.jl:12\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:8\r\n>  in todict at /home/a/.julia/v0.4/Mux/src/basics.jl:21\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:12 (repeats 2 times)\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/Mux.jl:8\r\n>  in anonymous at /home/a/.julia/v0.4/Mux/src/server.jl:38\r\n>  in handle at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:394\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/HttpServer.jl:393\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/RequestParser.jl:104ERROR (unhandled task failure): write: broken pipe (EPIPE)\r\n>  in yieldto at ./task.jl:71\r\n>  in wait at ./task.jl:371\r\n>  in stream_wait at ./stream.jl:60\r\n>  in uv_write at stream.jl:944\r\n>  in flush at stream.jl:979\r\n>  in locked_write at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:154\r\n>  in close at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:197\r\n>  in handle at /home/a/.julia/v0.4/WebSockets/src/WebSockets.jl:395\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/HttpServer.jl:393\r\n>  in on_message_complete at /home/a/.julia/v0.4/HttpServer/src/RequestParser.jl:1"},"comment":{"url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/comments/216035237","html_url":"https://github.com/JuliaWeb/WebSockets.jl/issues/51#issuecomment-216035237","issue_url":"https://api.github.com/repos/JuliaWeb/WebSockets.jl/issues/51","id":216035237,"user":{"login":"erikedin","id":324535,"avatar_url":"https://avatars.githubusercontent.com/u/324535?v=3","gravatar_id":"","url":"https://api.github.com/users/erikedin","html_url":"https://github.com/erikedin","followers_url":"https://api.github.com/users/erikedin/followers","following_url":"https://api.github.com/users/erikedin/following{/other_user}","gists_url":"https://api.github.com/users/erikedin/gists{/gist_id}","starred_url":"https://api.github.com/users/erikedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikedin/subscriptions","organizations_url":"https://api.github.com/users/erikedin/orgs","repos_url":"https://api.github.com/users/erikedin/repos","events_url":"https://api.github.com/users/erikedin/events{/privacy}","received_events_url":"https://api.github.com/users/erikedin/received_events","type":"User","site_admin":false},"created_at":"2016-05-01T11:11:50Z","updated_at":"2016-05-01T11:11:50Z","body":"At a glance I think an adapter buffer might be needed for TLS to work, because I don't think MbedTLS.SSLContext supports byte I/O. That is, when reading a frame and calling `read(b, UInt8)` you'll get an exception from MbedTLS. It only supports `readavailable` and `readbytes`, I think.\r\nIf I'm right it would be necessary to make a stream which wraps an MbedTLS.SSLContext stream, and allows calls to `read(::IO, ::Type{T})`, but only uses `readavailable(::IO)` on the TLS stream. That can't be very hard though."}}