hackney_ssl (hackney v4.0.2)

View Source

Summary

Functions

Generate ALPN options for SSL connection. Returns a list containing alpn_advertised_protocols option based on the protocols specified in Options.

Close a TCP socket.

Assign a new controlling process Pid to Socket.

Get the negotiated protocol after SSL handshake. Returns http2 if HTTP/2 was negotiated, http1 otherwise. Note: HTTP/3 is not returned here as it uses QUIC, not TLS.

Atoms used to identify messages in {active, once | true} mode.

Return the peer certificate of an SSL connection.

Return the address and port for the other end of a connection.

Receive a packet from a socket in passive mode.

Send a packet on a socket.

Set one or more options for a socket.

Immediately close a socket in one or two directions.

Get the local address and port of a socket

Build SSL options for a connection. Used by proxy modules for SSL upgrade after tunnel establishment.

Functions

alpn_opts(Opts)

-spec alpn_opts(list()) -> list().

Generate ALPN options for SSL connection. Returns a list containing alpn_advertised_protocols option based on the protocols specified in Options.

Options: - protocols: list of atoms [http3, http2, http1] (default: [http2, http1]) Order matters - first protocol is preferred Note: http3 is only used for informational purposes here - HTTP/3 uses QUIC which has its own ALPN negotiation handled by hackney_http3.

Example:

  alpn_opts([{protocols, [http2, http1]}]) ->
      [{alpn_advertised_protocols, [<<"h2">>, <<"http/1.1">>]}]

check_hostname_opts(Host0)

cipher_opts()

close(Socket)

-spec close(ssl:sslsocket()) -> ok.

Close a TCP socket.

See also: ssl:close/1.

connect(Host, Port, Opts)

connect(Host, Port, Opts0, Timeout)

controlling_process(Socket, Pid)

-spec controlling_process(ssl:sslsocket(), pid()) -> ok | {error, closed | not_owner | atom()}.

Assign a new controlling process Pid to Socket.

See also: ssl:controlling_process/2.

get_negotiated_protocol(SslSocket)

-spec get_negotiated_protocol(ssl:sslsocket()) -> http2 | http1.

Get the negotiated protocol after SSL handshake. Returns http2 if HTTP/2 was negotiated, http1 otherwise. Note: HTTP/3 is not returned here as it uses QUIC, not TLS.

See also: ssl:negotiated_protocol/1.

messages(_)

Atoms used to identify messages in {active, once | true} mode.

peercert(Socket)

-spec peercert(ssl:sslsocket()) -> {ok, binary()} | {error, atom()}.

Return the peer certificate of an SSL connection.

See also: ssl:peercert/1.

peername(Socket)

-spec peername(ssl:sslsocket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}.

Return the address and port for the other end of a connection.

See also: ssl:peername/1.

recv(Socket, Length)

recv(Socket, Length, Timeout)

-spec recv(ssl:sslsocket(), non_neg_integer(), timeout()) -> {ok, any()} | {error, closed | atom()}.

Receive a packet from a socket in passive mode.

See also: ssl:recv/3.

send(Socket, Packet)

-spec send(ssl:sslsocket(), iolist()) -> ok | {error, atom()}.

Send a packet on a socket.

See also: ssl:send/2.

setopts(Socket, Opts)

-spec setopts(ssl:sslsocket(), list()) -> ok | {error, atom()}.

Set one or more options for a socket.

See also: ssl:setopts/2.

shutdown(Socket, How)

-spec shutdown(ssl:sslsocket(), read | write | read_write) -> ok | {error, any()}.

Immediately close a socket in one or two directions.

See also: ssl:shutdown/2.

sockname(Socket)

-spec sockname(ssl:sslsocket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}.

Get the local address and port of a socket

See also: ssl:sockname/1.

ssl_opts(Host, Options)

Build SSL options for a connection. Used by proxy modules for SSL upgrade after tunnel establishment.