Module ssl2

Main API module for SSL2.

Copyright © (C) 2015 ACK CYFRONET AGH This software is released under the MIT license cited in 'LICENSE.md'.

Authors: Konrad Zemek.

Description

Main API module for SSL2.

Data Types

acceptor()

abstract datatype: acceptor()

der_encoded()

der_encoded() = binary()

option()

option() = {packet, raw | 0 | 1 | 2 | 4} | {active, boolean() | once} | {exit_on_close, boolean()}

pem_encoded()

pem_encoded() = binary()

socket()

abstract datatype: socket()

ssl_option()

ssl_option() = {verify_type, verify_none | verify_peer} | {fail_if_no_peer_cert, boolean()} | {verify_client_once, boolean()} | {rfc2818_verification_hostname, str()} | {cacerts, [pem_encoded()]} | {crls, [pem_encoded()]} | {certfile, str()} | {keyfile, str()} | {chain, [pem_encoded()]}

str()

str() = binary() | string()

Function Index

accept/1Equivalent to accept(Acceptor, infinity).
accept/2 Accepts an incoming connection on an acceptor.
certificate_chain/1 Returns a DER-encoded chain of peer certificates.
close/1 Gracefully closes the socket.
connect/3Equivalent to connect(Host, Port, Opts, infinity).
connect/4 Opens an ssl connection to Host, Port.
controlling_process/2 Assigns a new controlling process to the socket.
handshake/1Equivalent to handshake(Socket, infinity).
handshake/2 Performs a TLS handshake on the new TCP socket.
listen/2 Creates an acceptor (listen socket).
peercert/1 Returns a DER-encoded public certificate of the peer.
peername/1 Returns the address and port number of the peer.
recv/2Equivalent to recv(Socket, Size, infinity).
recv/3 Receives a packet from a socket in passive mode.
send/2 Writes Data to Socket.
setopts/2 Sets options according to Options for the socket Socket.
shutdown/2 Shuts down the connection in one or two directions.
sockname/1 Returns the address and port number of the socket.

Function Details

accept/1

accept(Acceptor::acceptor()) -> {ok, Socket::socket()} | {error, Reason::timeout | atom()}

Equivalent to accept(Acceptor, infinity).

accept/2

accept(Acceptor::acceptor(), Timeout::timeout()) -> {ok, Socket::socket()} | {error, Reason::timeout | atom()}

Accepts an incoming connection on an acceptor. The returned socket should be passed to ssl2:handshake to establish the secure connection.

certificate_chain/1

certificate_chain(Socket::socket()) -> {ok, [der_encoded()]} | {error, Reason::atom()}

Returns a DER-encoded chain of peer certificates.

close/1

close(Socket::socket()) -> ok | {error, Reason::atom()}

Gracefully closes the socket.

connect/3

connect(Host::str(), Port::inet:port_number(), Opts::[option() | ssl_option()]) -> {ok, Socket::socket()} | {error, Reason::atom()}

Equivalent to connect(Host, Port, Opts, infinity).

connect/4

connect(Host::str(), Port::inet:port_number(), Opts::[option() | ssl_option()], Timeout::timeout()) -> {ok, Socket::socket()} | {error, Reason::atom()}

Opens an ssl connection to Host, Port.

controlling_process/2

controlling_process(Socket::socket(), NewControllingProcess::pid()) -> ok

Assigns a new controlling process to the socket. A controlling process receives all messages from the socket.

handshake/1

handshake(Socket::socket()) -> ok | {error, Reason::atom()}

Equivalent to handshake(Socket, infinity).

handshake/2

handshake(Socket::socket(), Timeout::timeout()) -> ok | {error, Reason::timeout | any()}

Performs a TLS handshake on the new TCP socket. The socket should be created by ssl2:accept .

listen/2

listen(Port::inet:port_number(), Opts::[ssl_option()]) -> {ok, Acceptor::acceptor()} | {error, Reason::atom()}

Creates an acceptor (listen socket).

peercert/1

peercert(Socket::socket()) -> {ok, der_encoded()} | {error, Reason::no_peer_certificate | atom()}

Returns a DER-encoded public certificate of the peer.

peername/1

peername(Socket::socket()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, Reason::atom()}

Returns the address and port number of the peer.

recv/2

recv(Socket::socket(), Size::non_neg_integer()) -> {ok, binary()} | {error, Reason::closed | timeout | atom()}

Equivalent to recv(Socket, Size, infinity).

recv/3

recv(Socket::socket(), Size::non_neg_integer(), Timeout::timeout()) -> {ok, binary()} | {error, Reason::closed | timeout | atom()}

Receives a packet from a socket in passive mode. If the socket is closed, returns {error, closed}.

send/2

send(Socket::socket(), Data::iodata()) -> ok | {error, Reason::closed | atom()}

Writes Data to Socket. If the socket is closed, returns {error, closed}.

setopts/2

setopts(Socket::socket(), Opts::[option()]) -> ok

Sets options according to Options for the socket Socket.

shutdown/2

shutdown(Socket::socket(), Type::read | write | read_write) -> ok | {error, Reason::atom()}

Shuts down the connection in one or two directions. To be able to handle that the peer has done a shutdown on the write side, the {exit_on_close, false} option is useful.

sockname/1

sockname(SocketOrAcceptor::socket() | acceptor()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, Reason::atom()}

Returns the address and port number of the socket.


Generated by EDoc, Jun 12 2016, 00:01:17.