erps v0.4.2 Erps.Transport.Tls View Source
implements a two-way TLS transport strategy.
this transport is useful when you have trusted clients and servers that are authenticated against each other and must have an encrypted channel over WAN.
extra options:
:client_verify_fun
see:Erps.Server
Link to this section Summary
Functions
Callback implementation for Erps.Transport.Api.accept/2
.
Callback implementation for Erps.Transport.Api.connect/3
.
(server) a specialized function that generates a match function option used to verify that the incoming client is bound to a single ip address.
(server) opens a TCP port to listen for incoming connection requests.
Callback implementation for Erps.Transport.Api.recv/2
, via :ssl.recv/2
.
Callback implementation for Erps.Transport.Api.recv/3
, via :ssl.recv/3
.
Callback implementation for Erps.Transport.Api.send/2
, via :ssl.send/2
.
(client) responds to a server TLS handshake/2
request, by upgrading to an encrypted connection.
Verifies the identity of the server CA, and reject if it's not a valid peer.
Link to this section Types
socket()
View Source
socket() :: Erps.Transport.Api.socket()
socket() :: Erps.Transport.Api.socket()
Link to this section Functions
accept(sock, timeout) View Source
Callback implementation for Erps.Transport.Api.accept/2
.
connect(host, port, opts)
View Source
connect(term(), :inet.port_number(), keyword()) ::
{:ok, socket()} | {:error, term()}
connect(term(), :inet.port_number(), keyword()) :: {:ok, socket()} | {:error, term()}
Callback implementation for Erps.Transport.Api.connect/3
.
handshake(socket, tls_opts!)
View Source
handshake(:inet.socket(), keyword()) ::
{:ok, Erps.Transport.Api.socket()} | {:error, any()}
handshake(:inet.socket(), keyword()) :: {:ok, Erps.Transport.Api.socket()} | {:error, any()}
(server) a specialized function that generates a match function option used to verify that the incoming client is bound to a single ip address.
listen(port, opts)
View Source
listen(:inet.port_number(), keyword()) ::
{:ok, :inet.socket()} | {:error, any()}
listen(:inet.port_number(), keyword()) :: {:ok, :inet.socket()} | {:error, any()}
(server) opens a TCP port to listen for incoming connection requests.
Verifies that the tls options :cacertfile
, :certfile
, and :keyfile
exist
under the keyword :tls_opts
, and point to existing files (but not the validity
of their authority chain or their crytographic signing).
Callback implementation for Erps.Transport.Api.listen/2
.
recv(sock, length)
View Source
recv(socket(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}
recv(socket(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}
Callback implementation for Erps.Transport.Api.recv/2
, via :ssl.recv/2
.
recv(sock, length, timeout)
View Source
recv(socket(), non_neg_integer(), timeout()) ::
{:ok, binary()} | {:error, term()}
recv(socket(), non_neg_integer(), timeout()) :: {:ok, binary()} | {:error, term()}
Callback implementation for Erps.Transport.Api.recv/3
, via :ssl.recv/3
.
send(sock, content) View Source
Callback implementation for Erps.Transport.Api.send/2
, via :ssl.send/2
.
upgrade(socket, tls_opts)
View Source
upgrade(socket(), keyword()) :: {:ok, :ssl.socket()} | {:error, term()}
upgrade(socket(), keyword()) :: {:ok, :ssl.socket()} | {:error, term()}
(client) responds to a server TLS handshake/2
request, by upgrading to an encrypted connection.
Verifies the identity of the server CA, and reject if it's not a valid peer.
Callback implementation for Erps.Transport.Api.upgrade/2
.