Skip to content
This repository
Browse code

fix SSL Websocket support (Dan Willemsen)

fixed a case where a gen_tcp call was erroneously being used on an SSL
socket
  • Loading branch information...
commit c25ed57b0f56f9f313668b9f7e24ff8697842760 1 parent 40fac1e
Dan Willemsen danw authored vinoski committed

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. +6 1 src/yaws_websockets.erl
7 src/yaws_websockets.erl
@@ -58,7 +58,12 @@ handshake(Arg, ContentPid, SocketMode) ->
58 58 exit(normal).
59 59
60 60 handshake(ws_76, Arg, CliSock, WebSocketLocation, Origin, Protocol) ->
61   - {ok, Challenge} = gen_tcp:recv(CliSock, 8),
  61 + {ok, Challenge} = case CliSock of
  62 + {sslsocket, _, _} ->
  63 + ssl:recv(CliSock, 8);
  64 + _ ->
  65 + gen_tcp:recv(CliSock, 8)
  66 + end,
62 67 Key1 = secret_key("sec-websocket-key1", Arg#arg.headers),
63 68 Key2 = secret_key("sec-websocket-key2", Arg#arg.headers),
64 69 ChallengeResponse = challenge(Key1, Key2, binary_to_list(Challenge)),

0 comments on commit c25ed57

Please sign in to comment.
Something went wrong with that request. Please try again.