Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. -module(dtls_client).
  2.  
  3. -export([connect/1]).
  4.  
  5. psk_verify(Username, UserState) ->
  6. io:format("Server Hint: ~p~n", [Username]),
  7. {ok, UserState}.
  8.  
  9. connect(Port) ->
  10. [application:start(X) || X <- [crypto, asn1, public_key, ssl]],
  11.  
  12. %% Opts = [{ciphers,[{dhe_dss,aes_256_cbc,sha256}]},
  13. Opts = [
  14. {ssl_imp,new},
  15. {active, false},
  16. {verify, 0},
  17.  
  18. {protocol, dtls},
  19. {versions, ['dtlsv1.2']},
  20. %% {ciphers,[{ecdhe_rsa, aes_128_cbc, sha256}]},
  21. {cb_info, {dtls_udp, dtls_udp, udp_close, udp_error}}
  22.  
  23. %% {versions, ['tlsv1.2']},
  24. %% {ciphers,[{ecdhe_rsa,chacha20_poly1305,null}]}
  25.  
  26. %% {srp_identity, {"Test-User", "secret"}},
  27. %% {ciphers, [{srp_anon, aes_256_cbc, sha}]},
  28. %% {psk_identity, "Client_identity"},
  29. %% {psk_lookup_fun, {fun psk_verify/2, <<16#11>>}},
  30. %% {versions, [tlsv1]},
  31. %% {ciphers,[{rsa_psk, aes_256_cbc, sha}]},
  32. %% {reuseaddr,true}
  33. ],
  34.  
  35. %%{ok, Host} = inet:gethostname(),
  36. Host = {127,0,0,1},
  37. {ok, CSock} = ssl:connect(Host, Port, Opts),
  38. io:fwrite("Connect: connected.~n"),
  39. {ok, Data} = ssl:recv(CSock, 0),
  40. io:fwrite("Connect: got data: ~p~n", [Data]),
  41. io:fwrite("Connect: closing and terminating.~n"),
  42. ssl:close(CSock).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement