From e042afe54727ae490d47eae47c6d9a210f04dd47 Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Mon, 10 Sep 2018 11:19:42 +0200 Subject: ssl: Use specs to generate type documentation --- lib/ssl/doc/src/ssl.xml | 1678 ++++++++++++++++++++++++++--------------------- 1 file changed, 941 insertions(+), 737 deletions(-) (limited to 'lib/ssl/doc/src/ssl.xml') diff --git a/lib/ssl/doc/src/ssl.xml b/lib/ssl/doc/src/ssl.xml index 586452efd4..21ea1be4b4 100644 --- a/lib/ssl/doc/src/ssl.xml +++ b/lib/ssl/doc/src/ssl.xml @@ -37,274 +37,333 @@ ssl(6).

- -
- DATA TYPES -

The following data types are used in the functions for SSL/TLS/DTLS:

- - - - boolean() = -

true | false

- - option() = -

socketoption() | ssl_option() | transport_option()

-
- - socketoption() = -

proplists:property()

-

The default socket options are - [{mode,list},{packet, 0},{header, 0},{active, true}].

-

For valid options, see the - inet(3), - gen_tcp(3) and - gen_udp(3) - manual pages - in Kernel. Note that stream oriented options such as packet are only relevant for SSL/TLS and not DTLS

- - ssl_option() = - -

{verify, verify_type()}

-

| {verify_fun, {fun(), term()}}

-

| {fail_if_no_peer_cert, boolean()}

-

| {depth, integer()}

-

| {cert, public_key:der_encoded()}

-

| {certfile, path()}

-

| {key, {'RSAPrivateKey'| 'DSAPrivateKey' | 'ECPrivateKey' - | 'PrivateKeyInfo', public_key:der_encoded()} | - #{algorithm := rsa | dss | ecdsa, - engine := crypto:engine_ref(), key_id := crypto:key_id(), password => crypto:password()}

-

| {keyfile, path()}

-

| {password, string()}

-

| {cacerts, [public_key:der_encoded()]}

-

| {cacertfile, path()}

-

| {dh, public_key:der_encoded()}

-

| {dhfile, path()}

-

| {ciphers, ciphers()}

-

| {user_lookup_fun, {fun(), term()}}, {psk_identity, string()}, - {srp_identity, {string(), string()}}

-

| {reuse_sessions, boolean() | save()}

-

| {reuse_session, fun() | binary()}

-

| {next_protocols_advertised, [binary()]}

-

| {client_preferred_next_protocols, {client | server, - [binary()]} | {client | server, [binary()], binary()}}

-

| {log_alert, boolean()}

-

| {server_name_indication, hostname() | disable}

-

| {customize_hostname_check, list()}

-

| {sni_hosts, [{hostname(), [ssl_option()]}]}

-

| {sni_fun, SNIfun::fun()}

-
- - transport_option() = -

{cb_info, {CallbackModule::atom(), DataTag::atom(), - - ClosedTag::atom(), ErrTag:atom()}}

-

Defaults to {gen_tcp, tcp, tcp_closed, tcp_error} for TLS - and {gen_udp, udp, udp_closed, udp_error} for DTLS. Can be used - to customize the transport layer. For TLS the callback module must implement a - reliable transport protocol, behave as gen_tcp, and have functions - corresponding to inet:setopts/2, inet:getopts/2, - inet:peername/1, inet:sockname/1, and inet:port/1. - The callback gen_tcp is treated specially and calls inet - directly. For DTLS this feature must be considered exprimental.

- - CallbackModule = -

atom()

- DataTag = -

atom()

-

Used in socket data message.

- ClosedTag = -

atom()

-

Used in socket close message.

-
-
- - verify_type() = -

verify_none | verify_peer

- - path() = -

string()

-

Represents a file path.

- public_key:der_encoded() = -

binary()

-

ASN.1 DER-encoded entity as an Erlang binary.

+ - host() = -

hostname() | ipaddress()

+ + Types used in SSL/TLS/DTLS - hostname() = -

string() - DNS hostname

+ + + + + + + + +

An opaque reference to the TLS/DTLS connection.

+
+
+ + + + + + + + + + + + + + + + + +

The default socket options are + [{mode,list},{packet, 0},{header, 0},{active, true}].

+

For valid options, see the + inet(3), + gen_tcp(3) and + gen_udp(3) + manual pages in Kernel. Note that stream oriented options such as packet + are only relevant for SSL/TLS and not DTLS

+
+
- ip_address() = -

{N1,N2,N3,N4} % IPv4 | {K1,K2,K3,K4,K5,K6,K7,K8} % IPv6 -

+ + + + + + + - sslsocket() = -

opaque()

- - protocol_version() = -

ssl_tls_protocol() | dtls_protocol()

- -

sslv3 | tlsv1 | 'tlsv1.1' | 'tlsv1.2'

- - dtls_protocol() = -

'dtlsv1' | 'dtlsv1.2'

- - ciphers() = -

= [ciphersuite()]

-

Tuples and string formats accepted by versions - before ssl-8.2.4 will be converted for backwards compatibility

- - ciphersuite() = -

- #{key_exchange := key_exchange(), - cipher := cipher(), - mac := MAC::hash() | aead, - prf := PRF::hash() | default_prf}

- - key_exchange()= -

rsa | dhe_dss | dhe_rsa | dh_anon | psk | dhe_psk - | rsa_psk | srp_anon | srp_dss | srp_rsa | ecdh_anon | ecdh_ecdsa - | ecdhe_ecdsa | ecdh_rsa | ecdhe_rsa

- - cipher() = -

rc4_128 | des_cbc | '3des_ede_cbc' - | aes_128_cbc | aes_256_cbc | aes_128_gcm | aes_256_gcm | chacha20_poly1305

- - hash() = -

md5 | sha | sha224 | sha256 | sha348 | sha512

- - prf_random() = -

client_random | server_random

- - cipher_filters() = -

[{key_exchange | cipher | mac | prf, algo_filter()}])

- - algo_filter() = -

fun(key_exchange() | cipher() | hash() | aead | default_prf) -> true | false

- - srp_param_type() = -

srp_1024 | srp_1536 | srp_2048 | srp_3072 - | srp_4096 | srp_6144 | srp_8192

- - SNIfun::fun() -

= fun(ServerName :: string()) -> [ssl_option()]

- - named_curve() = -

sect571r1 | sect571k1 | secp521r1 | brainpoolP512r1 - | sect409k1 | sect409r1 | brainpoolP384r1 | secp384r1 - | sect283k1 | sect283r1 | brainpoolP256r1 | secp256k1 | secp256r1 - | sect239k1 | sect233k1 | sect233r1 | secp224k1 | secp224r1 - | sect193r1 | sect193r2 | secp192k1 | secp192r1 | sect163k1 - | sect163r1 | sect163r2 | secp160k1 | secp160r1 | secp160r2

- - hello_extensions() = -

#{renegotiation_info => binary() | undefined, - signature_algs => [{hash(), ecsda| rsa| dsa}] | undefined - alpn => binary() | undefined, - next_protocol_negotiation => binary() | undefined, - srp => string() | undefined, - ec_point_formats => list() | undefined, - elliptic_curves => [oid] | undefined, - sni => string() | undefined} - }

+ + + +

When an TLS/DTLS socket is in active mode (the default), data from the + socket is delivered to the owner of the socket in the form of + messages as described above.

+
+
+ + + +

Defaults to {gen_tcp, tcp, tcp_closed, tcp_error} + for TLS and {gen_udp, udp, udp_closed, udp_error} for + DTLS. Can be used to customize the transport layer. The tag + values should be the values used by the underlying transport + in its active mode messages. For TLS the callback module must implement a + reliable transport protocol, behave as gen_tcp, and have functions + corresponding to inet:setopts/2, inet:getopts/2, + inet:peername/1, inet:sockname/1, and inet:port/1. + The callback gen_tcp is treated specially and calls inet + directly. For DTLS this feature must be considered exprimental. +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-
+ + + -
- TLS/DTLS OPTION DESCRIPTIONS - COMMON for SERVER and CLIENT + + + -

The following options have the same meaning in the client and - the server:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TLS/DTLS OPTION DESCRIPTIONS - COMMON for SERVER and CLIENT - - - {protocol, tls | dtls} -

Choose TLS or DTLS protocol for the transport layer security. - Defaults to tls Introduced in OTP 20, DTLS support is considered - experimental in this release. Other transports than UDP are not yet supported.

- - {handshake, hello | full} -

Defaults to full. If hello is specified the handshake will - pause after the hello message and give the user a possibility make decisions - based on hello extensions before continuing or aborting the handshake by calling - handshake_continue/3 or - handshake_cancel/1 -

- - {cert, public_key:der_encoded()} -

The DER-encoded users certificate. If this option - is supplied, it overrides option certfile.

- - {certfile, path()} -

Path to a file containing the user certificate.

- - - - {key, {'RSAPrivateKey'| 'DSAPrivateKey' | 'ECPrivateKey' - |'PrivateKeyInfo', public_key:der_encoded()} | #{algorithm := rsa | dss | ecdsa, - engine := crypto:engine_ref(), key_id := crypto:key_id(), password => crypto:password()} -

The DER-encoded user's private key or a map refering to a crypto - engine and its key reference that optionally can be password protected, - seealso crypto:engine_load/4 - and Crypto's Users Guide. If this option - is supplied, it overrides option keyfile.

- - {keyfile, path()} -

Path to the file containing the user's - private PEM-encoded key. As PEM-files can contain several - entries, this option defaults to the same file as given by - option certfile.

- - {password, string()} -

String containing the user's password. Only used if the - private keyfile is password-protected.

- - {ciphers, ciphers()} -

Supported cipher suites. The function - cipher_suites/0 can be used to find all ciphers that are - supported by default. cipher_suites(all) can be called - to find all available cipher suites. Pre-Shared Key - (RFC 4279 and - RFC 5487), - Secure Remote Password - (RFC 5054), RC4 cipher suites, - and anonymous cipher suites only work if explicitly enabled by - this option; they are supported/enabled by the peer also. - Anonymous cipher suites are supported for testing purposes - only and are not be used when security matters.

- - {eccs, [named_curve()]} -

Allows to specify the order of preference for named curves - and to restrict their usage when using a cipher suite supporting them. -

- - {secure_renegotiate, boolean()} -

Specifies if to reject renegotiation attempt that does - not live up to - RFC 5746. - By default secure_renegotiate is set to true, - that is, secure renegotiation is enforced. If set to false secure renegotiation - will still be used if possible, - but it falls back to insecure renegotiation if the peer - does not support - RFC 5746.

-
- - {depth, integer()} -

Maximum number of non-self-issued + + + + + + + +

Choose TLS or DTLS protocol for the transport layer security. + Defaults to tls. For DTLS other transports than UDP are not yet supported.

+ + + + + + +

Defaults to full. If hello is specified the handshake will + pause after the hello message and give the user a possibility make decisions + based on hello extensions before continuing or aborting the handshake by calling + handshake_continue/3 or + handshake_cancel/1

+
+
+ + + + +

The DER-encoded users certificate. If this option + is supplied, it overrides option certfile.

+
+
+ + + + +

Path to a file containing the user certificate on PEM format.

+
+
+ + + + +

The DER-encoded user's private key or a map refering to a crypto + engine and its key reference that optionally can be password protected, + seealso crypto:engine_load/4 + and Crypto's Users Guide. If this option + is supplied, it overrides option keyfile.

+
+
+ + + + +

Path to the file containing the user's + private PEM-encoded key. As PEM-files can contain several + entries, this option defaults to the same file as given by + option certfile.

+
+
+ + + + +

String containing the user's password. Only used if the + private keyfile is password-protected.

+
+
+ + + + +

Supported cipher suites. The function + cipher_suites/2 can be used to find all ciphers that + are supported by default. cipher_suites(all, 'tlsv1.2') can be + called to find all available cipher suites. Pre-Shared Key + (RFC + 4279 and RFC 5487), + Secure Remote Password (RFC 5054), + RC4, 3DES, DES cipher suites, and anonymous cipher suites only work if + explicitly enabled by this option; they are supported/enabled + by the peer also. Anonymous cipher suites are supported for + testing purposes only and are not be used when security + matters.

+
+
+ + + +

Allows to specify the order of preference for named curves + and to restrict their usage when using a cipher suite supporting them.

+
+
+ + + +

Specifies if to reject renegotiation attempt that does + not live up to RFC 5746. By + default secure_renegotiate is set to true, that + is, secure renegotiation is enforced. If set to false + secure renegotiation will still be used if possible, but it + falls back to insecure renegotiation if the peer does not + support RFC + 5746.

+
+
+ + + +

Maximum number of non-self-issued intermediate certificates that can follow the peer certificate in a valid certification path. So, if depth is 0 the PEER must be signed by the trusted ROOT-CA directly; if 1 the path can be PEER, CA, ROOT-CA; if 2 the path can be PEER, CA, CA, - ROOT-CA, and so on. The default value is 1.

- - {verify_fun, {Verifyfun :: fun(), InitialUserState :: - term()}} -

The verification fun is to be defined as follows:

+ ROOT-CA, and so on. The default value is 1.

+ + + + + + +

The verification fun is to be defined as follows:

fun(OtpCert :: #'OTPCertificate'{}, Event :: {bad_cert, Reason :: atom() | {revoked, @@ -316,20 +375,21 @@ atom()}} |

The verification fun is called during the X509-path validation when an error or an extension unknown to the SSL - application is encountered. It is also called - when a certificate is considered valid by the path validation - to allow access to each certificate in the path to the user - application. It differentiates between the peer - certificate and the CA certificates by using valid_peer or - valid as second argument to the verification fun. See the - public_key User's - Guide for definition of #'OTPCertificate'{} and - #'Extension'{}.

+ application is encountered. It is also called when a + certificate is considered valid by the path validation to + allow access to each certificate in the path to the user + application. It differentiates between the peer certificate + and the CA certificates by using valid_peer or + valid as second argument to the verification fun. See + the public_key + User's Guide for definition of + #'OTPCertificate'{} and #'Extension'{}.

-

If the verify callback fun returns {fail, Reason}, - the verification process is immediately stopped, an alert is - sent to the peer, and the TLS/DTLS handshake terminates.

+

If the verify callback fun returns {fail, + Reason}, the verification process is immediately + stopped, an alert is sent to the peer, and the TLS/DTLS + handshake terminates.

If the verify callback fun returns {valid, UserState}, the verification process continues.

If the verify callback fun always returns @@ -379,10 +439,12 @@ atom()}} | unknown_ca -

No trusted CA was found in the trusted store. The trusted CA is - normally a so called ROOT CA, which is a self-signed certificate. Trust can - be claimed for an intermediate CA (trusted anchor does not have to be - self-signed according to X-509) by using option partial_chain.

+

No trusted CA was found in the trusted store. The + trusted CA is normally a so called ROOT CA, which is a + self-signed certificate. Trust can be claimed for an + intermediate CA (trusted anchor does not have to be + self-signed according to X-509) by using option + partial_chain.

selfsigned_peer @@ -393,15 +455,17 @@ atom()}} | marker="public_key:public_key#pkix_path_validation-3">public_key:pkix_path_validation/3

- - - {crl_check, boolean() | peer | best_effort } - + + + + + +

Perform CRL (Certificate Revocation List) verification - (public_key:pkix_crls_validate/3) on all the certificates during the path validation - (public_key:pkix_path_validation/3) + (public_key:pkix_crls_validate/3) on all the + certificates during the path validation (public_key:pkix_path_validation/3) of the certificate chain. Defaults to false.

@@ -413,106 +477,104 @@ marker="public_key:public_key#pkix_path_validation-3">public_key:pkix_path_valid if certificate revocation status can not be determined it will be accepted as valid. - +

The CA certificates specified for the connection will be used to construct the certificate chain validating the CRLs.

The CRLs will be fetched from a local or external cache. See ssl_crl_cache_api(3).

-
- - {crl_cache, {Module :: atom(), {DbHandle :: internal | term(), Args :: list()}}} - -

Specify how to perform lookup and caching of certificate revocation lists. - Module defaults to ssl_crl_cache - with DbHandle being internal and an - empty argument list.

- -

There are two implementations available:

- - - ssl_crl_cache - -

This module maintains a cache of CRLs. CRLs can be - added to the cache using the function ssl_crl_cache:insert/1, - and optionally automatically fetched through HTTP if the - following argument is specified:

- - - {http, timeout()} -

- Enables fetching of CRLs specified as http URIs inX509 certificate extensions. - Requires the OTP inets application.

-
-
-
- - ssl_crl_hash_dir - -

This module makes use of a directory where CRLs are - stored in files named by the hash of the issuer name.

- -

The file names consist of eight hexadecimal digits - followed by .rN, where N is an integer, - e.g. 1a2b3c4d.r0. For the first version of the - CRL, N starts at zero, and for each new version, - N is incremented by one. The OpenSSL utility - c_rehash creates symlinks according to this - pattern.

- -

For a given hash value, this module finds all - consecutive .r* files starting from zero, and those - files taken together make up the revocation list. CRL - files whose nextUpdate fields are in the past, or - that are issued by a different CA that happens to have the - same name hash, are excluded.

- -

The following argument is required:

- - - {dir, string()} -

Specifies the directory in which the CRLs can be found.

-
- -
- - max_handshake_size - -

Integer (24 bits unsigned). Used to limit the size of - valid TLS handshake packets to avoid DoS attacks. - Defaults to 256*1024.

-
- -
- -
+ + - {partial_chain, fun(Chain::[DerCert]) -> {trusted_ca, DerCert} | - unknown_ca } -

Claim an intermediate CA in the chain as trusted. TLS then - performs public_key:pkix_path_validation/3 - with the selected CA as trusted anchor and the rest of the chain.

+ + + +

Specify how to perform lookup and caching of certificate revocation lists. + Module defaults to ssl_crl_cache + with DbHandle being internal and an + empty argument list.

+ +

There are two implementations available:

+ + + ssl_crl_cache + +

This module maintains a cache of CRLs. CRLs can be + added to the cache using the function ssl_crl_cache:insert/1, + and optionally automatically fetched through HTTP if the + following argument is specified:

+ + + {http, timeout()} +

+ Enables fetching of CRLs specified as http URIs inX509 certificate extensions. + Requires the OTP inets application.

+
+
+
+ + ssl_crl_hash_dir + +

This module makes use of a directory where CRLs are + stored in files named by the hash of the issuer name.

+ +

The file names consist of eight hexadecimal digits + followed by .rN, where N is an integer, + e.g. 1a2b3c4d.r0. For the first version of the + CRL, N starts at zero, and for each new version, + N is incremented by one. The OpenSSL utility + c_rehash creates symlinks according to this + pattern.

+ +

For a given hash value, this module finds all + consecutive .r* files starting from zero, and those + files taken together make up the revocation list. CRL + files whose nextUpdate fields are in the past, or + that are issued by a different CA that happens to have the + same name hash, are excluded.

+ +

The following argument is required:

+ + + {dir, string()} +

Specifies the directory in which the CRLs can be found.

+
+
+
+
+
+ + + + + +fun(Chain::[public_key:der_encoded()]) -> + {trusted_ca, DerCert::public_key:der_encoded()} | unknown_ca} + +

Claim an intermediate CA in the chain as trusted. TLS then + performs public_key:pkix_path_validation/3 + with the selected CA as trusted anchor and the rest of the chain.

+
+
- {versions, [protocol_version()]} -

TLS protocol versions supported by started clients and servers. + + +

TLS protocol versions supported by started clients and servers. This option overrides the application environment option protocol_version and dtls_protocol_version. If the environment option is not set, it defaults to all versions, except SSL-3.0, supported by the SSL application. - See also ssl(6).

+ See also ssl(6).

+ + - {hibernate_after, integer()|undefined} -

When an integer-value is specified, TLS/DTLS-connection - goes into hibernation after the specified number of milliseconds - of inactivity, thus reducing its memory footprint. When - undefined is specified (this is the default), the process - never goes into hibernation.

- {user_lookup_fun, {Lookupfun :: fun(), UserState :: term()}} -

The lookup fun is to defined as follows:

+ + +

The lookup fun is to defined as follows:

fun(psk, PSKIdentity ::string(), UserState :: term()) -> @@ -534,20 +596,54 @@ fun(srp, Username :: string(), UserState :: term()) -> RFC 5054: crypto:sha([Salt, crypto:sha([Username, <<$:>>, Password])])

-
+ + - {padding_check, boolean()} -

Affects TLS-1.0 connections only. + + + +

Identifies a TLS session.

+ + + + + +

If set to false, error reports are not displayed.

+
+
+ + + +

When an integer-value is specified, TLS/DTLS-connection + goes into hibernation after the specified number of milliseconds + of inactivity, thus reducing its memory footprint. When + undefined is specified (this is the default), the process + never goes into hibernation.

+
+
+ + + + +

Integer (24 bits unsigned). Used to limit the size of + valid TLS handshake packets to avoid DoS attacks. + Defaults to 256*1024.

+
+
+ + + +

Affects TLS-1.0 connections only. If set to false, it disables the block cipher padding check to be able to interoperate with legacy software.

Using {padding_check, boolean()} makes TLS vulnerable to the Poodle attack.

-
- - + + - {beast_mitigation, one_n_minus_one | zero_n | disabled} -

Affects SSL-3.0 and TLS-1.0 connections only. Used to change the BEAST + + +

Affects SSL-3.0 and TLS-1.0 connections only. Used to change the BEAST mitigation strategy to interoperate with legacy software. Defaults to one_n_minus_one.

@@ -557,139 +653,166 @@ fun(srp, Username :: string(), UserState :: term()) ->

disabled - Disable BEAST mitigation.

-

Using {beast_mitigation, disabled} makes SSL or TLS +

Using {beast_mitigation, disabled} makes SSL-3.0 or TLS-1.0 vulnerable to the BEAST attack.

-
- - -
- -
- TLS/DTLS OPTION DESCRIPTIONS - CLIENT SIDE - -

The following options are client-specific or have a slightly different - meaning in the client than in the server:

+ + + - + TLS/DTLS OPTION DESCRIPTIONS - CLIENT + + + + + + + +

In mode verify_none the default behavior is to allow + all x509-path validation errors. See also option verify_fun.

+
+
- {verify, verify_type()} -

In mode verify_none the default behavior is to allow - all x509-path validation errors. See also option verify_fun.

-
- - {reuse_session, binary()} -

Reuses a specific session earlier saved with the option - {reuse_sessions, save} since ssl-9.2 -

+ + + +

Reuses a specific session earlier saved with the option + {reuse_sessions, save} since OTP-21.3 +

+
+
- {reuse_sessions, boolean() | save} -

When save is specified a new connection will be negotiated + + + +

When save is specified a new connection will be negotiated and saved for later reuse. The session ID can be fetched with - connection_information/2 - and used with the client option reuse_session + connection_information/2 + and used with the client option reuse_session The boolean value true specifies that if possible, automatized session reuse will be performed. If a new session is created, and is unique in regard - to previous stored sessions, it will be saved for possible later reuse. - Value save since ssl-9.2 -

- - {cacerts, [public_key:der_encoded()]} -

The DER-encoded trusted certificates. If this option - is supplied it overrides option cacertfile.

- - {cacertfile, path()} -

Path to a file containing PEM-encoded CA certificates. The CA + to previous stored sessions, it will be saved for possible later reuse. Since OTP-21.3

+ + + + + + +

The DER-encoded trusted certificates. If this option + is supplied it overrides option cacertfile.

+
+
+ + + + +

Path to a file containing PEM-encoded CA certificates. The CA certificates are used during server authentication and when building the client certificate chain.

-
- - {alpn_advertised_protocols, [binary()]} - -

The list of protocols supported by the client to be sent to the - server to be used for an Application-Layer Protocol Negotiation (ALPN). - If the server supports ALPN then it will choose a protocol from this - list; otherwise it will fail the connection with a "no_application_protocol" - alert. A server that does not support ALPN will ignore this value.

- -

The list of protocols must not contain an empty binary.

- -

The negotiated protocol can be retrieved using the negotiated_protocol/1 function.

-
- - {client_preferred_next_protocols, {Precedence :: server | client, ClientPrefs :: [binary()]}}
- {client_preferred_next_protocols, {Precedence :: server | client, ClientPrefs :: [binary()], Default :: binary()}}
- -

Indicates that the client is to try to perform Next Protocol - Negotiation.

- -

If precedence is server, the negotiated protocol is the - first protocol to be shown on the server advertised list, which is - also on the client preference list.

- -

If precedence is client, the negotiated protocol is the - first protocol to be shown on the client preference list, which is - also on the server advertised list.

- -

If the client does not support any of the server advertised - protocols or the server does not advertise any protocols, the - client falls back to the first protocol in its list or to the - default protocol (if a default is supplied). If the - server does not support Next Protocol Negotiation, the - connection terminates if no default protocol is supplied.

-
- - {psk_identity, string()} -

Specifies the identity the client presents to the server. - The matching secret is found by calling user_lookup_fun.

-
- - {srp_identity, {Username :: string(), Password :: string()} - -

Specifies the username and password to use to authenticate - to the server.

- - {server_name_indication, HostName :: hostname()} -

Specify the hostname to be used in TLS Server Name Indication extension. - If not specified it will default to the Host argument of connect/[3,4] - unless it is of type inet:ipaddress().

-

- The HostName will also be used in the hostname verification of the peer certificate using - public_key:pkix_verify_hostname/2. -

-
- {server_name_indication, disable} - -

Prevents the Server Name Indication extension from being sent and - disables the hostname verification check - public_key:pkix_verify_hostname/2

-
- - {customize_hostname_check, Options::list()} - -

Customizes the hostname verification of the peer certificate, as different protocols that use + + + + + + +

The list of protocols supported by the client to be sent to the + server to be used for an Application-Layer Protocol Negotiation (ALPN). + If the server supports ALPN then it will choose a protocol from this + list; otherwise it will fail the connection with a "no_application_protocol" + alert. A server that does not support ALPN will ignore this value.

+ +

The list of protocols must not contain an empty binary.

+ +

The negotiated protocol can be retrieved using the negotiated_protocol/1 function.

+ + + + + + +

Indicates that the client is to try to perform Next Protocol + Negotiation.

+ +

If precedence is server, the negotiated protocol is the + first protocol to be shown on the server advertised list, which is + also on the client preference list.

+ +

If precedence is client, the negotiated protocol is the + first protocol to be shown on the client preference list, which is + also on the server advertised list.

+ +

If the client does not support any of the server advertised + protocols or the server does not advertise any protocols, the + client falls back to the first protocol in its list or to the + default protocol (if a default is supplied). If the + server does not support Next Protocol Negotiation, the + connection terminates if no default protocol is supplied.

+
+
+ + + + +

Specifies the identity the client presents to the server. + The matching secret is found by calling user_lookup_fun

+
+
+ + + + +

Specifies the username and password to use to authenticate + to the server.

+
+
+ + + + +

Specify the hostname to be used in TLS Server Name Indication extension. + If not specified it will default to the Host argument of connect/[3,4] + unless it is of type inet:ipaddress().

+

+ The HostName will also be used in the hostname verification of the peer certificate using + public_key:pkix_verify_hostname/2. +

+

The special value disable prevents the Server Name Indication extension from being sent and + disables the hostname verification check + public_key:pkix_verify_hostname/2

+
+
+ + + + +

Customizes the hostname verification of the peer certificate, as different protocols that use TLS such as HTTP or LDAP may want to do it differently, for possible options see public_key:pkix_verify_hostname/3

-
- - {fallback, boolean()} - -

Send special cipher suite TLS_FALLBACK_SCSV to avoid undesired TLS version downgrade. - Defaults to false

-

Note this option is not needed in normal TLS usage and should not be used - to implement new clients. But legacy clients that retries connections in the following manner

- -

ssl:connect(Host, Port, [...{versions, ['tlsv2', 'tlsv1.1', 'tlsv1', 'sslv3']}])

-

ssl:connect(Host, Port, [...{versions, [tlsv1.1', 'tlsv1', 'sslv3']}, {fallback, true}])

-

ssl:connect(Host, Port, [...{versions, ['tlsv1', 'sslv3']}, {fallback, true}])

-

ssl:connect(Host, Port, [...{versions, ['sslv3']}, {fallback, true}])

- -

may use it to avoid undesired TLS version downgrade. Note that TLS_FALLBACK_SCSV must also - be supported by the server for the prevention to work. -

-
- {signature_algs, [{hash(), ecdsa | rsa | dsa}]} - -

In addition to the algorithms negotiated by the cipher + + + + + + +

Send special cipher suite TLS_FALLBACK_SCSV to avoid undesired TLS version downgrade. + Defaults to false

+

Note this option is not needed in normal TLS usage and should not be used + to implement new clients. But legacy clients that retries connections in the following manner

+ +

ssl:connect(Host, Port, [...{versions, ['tlsv2', 'tlsv1.1', 'tlsv1', 'sslv3']}])

+

ssl:connect(Host, Port, [...{versions, [tlsv1.1', 'tlsv1', 'sslv3']}, {fallback, true}])

+

ssl:connect(Host, Port, [...{versions, ['tlsv1', 'sslv3']}, {fallback, true}])

+

ssl:connect(Host, Port, [...{versions, ['sslv3']}, {fallback, true}])

+ +

may use it to avoid undesired TLS version downgrade. Note that TLS_FALLBACK_SCSV must also + be supported by the server for the prevention to work. +

+ + + + + + +

In addition to the algorithms negotiated by the cipher suite used for key exchange, payload encryption, message authentication and pseudo random calculation, the TLS signature algorithm extension Selected signature algorithm can restrict which hash functions that may be selected. Default support for {md5, rsa} removed in ssl-8.0

-
-
-
- -
- TLS/DTLS OPTION DESCRIPTIONS - SERVER SIDE + + + -

The following options are server-specific or have a slightly different - meaning in the server than in the client:

+ TLS/DTLS OPTION DESCRIPTIONS - SERVER - - {cacerts, [public_key:der_encoded()]} -

The DER-encoded trusted certificates. If this option - is supplied it overrides option cacertfile.

+ + + + + + +

The DER-encoded trusted certificates. If this option + is supplied it overrides option cacertfile.

+
+
- {cacertfile, path()} -

Path to a file containing PEM-encoded CA - certificates. The CA certificates are used to build the server - certificate chain and for client authentication. The CAs are - also used in the list of acceptable client CAs passed to the - client when a certificate is requested. Can be omitted if there - is no need to verify the client and if there are no - intermediate CAs for the server certificate.

- - {dh, public_key:der_encoded()} -

The DER-encoded Diffie-Hellman parameters. If specified, - it overrides option dhfile.

- - {dhfile, path()} -

Path to a file containing PEM-encoded Diffie Hellman parameters - to be used by the server if a cipher suite using Diffie Hellman key - exchange is negotiated. If not specified, default parameters are used. -

- - {verify, verify_type()} -

A server only does x509-path validation in mode verify_peer, - as it then sends a certificate request to the client - (this message is not sent if the verify option is verify_none). - You can then also want to specify option fail_if_no_peer_cert. -

- - {fail_if_no_peer_cert, boolean()} -

Used together with {verify, verify_peer} by an TLS/DTLS server. - If set to true, the server fails if the client does not have - a certificate to send, that is, sends an empty certificate. If set to - false, it fails only if the client sends an invalid - certificate (an empty certificate is considered valid). Defaults to false.

-
- - {reuse_sessions, boolean()} -

The boolean value true specifies that the server will - agree to reuse sessions. Setting it to false will result in an empty - session table, that is no sessions will be reused. - See also option reuse_session -

- - - {reuse_session, fun(SuggestedSessionId, - PeerCert, Compression, CipherSuite) -> boolean()} -

Enables the TLS/DTLS server to have a local policy - for deciding if a session is to be reused or not. - Meaningful only if reuse_sessions is set to true. - SuggestedSessionId is a binary(), PeerCert is - a DER-encoded certificate, Compression is an enumeration integer, - and CipherSuite is of type ciphersuite().

- - {alpn_preferred_protocols, [binary()]} - -

Indicates the server will try to perform Application-Layer - Protocol Negotiation (ALPN).

- -

The list of protocols is in order of preference. The protocol - negotiated will be the first in the list that matches one of the - protocols advertised by the client. If no protocol matches, the - server will fail the connection with a "no_application_protocol" alert.

- -

The negotiated protocol can be retrieved using the negotiated_protocol/1 function.

-
- - {next_protocols_advertised, Protocols :: [binary()]} -

List of protocols to send to the client if the client indicates that - it supports the Next Protocol extension. The client can select a protocol - that is not on this list. The list of protocols must not contain an empty - binary. If the server negotiates a Next Protocol, it can be accessed - using the negotiated_next_protocol/1 method.

- - {psk_identity, string()} -

Specifies the server identity hint, which the server presents to - the client.

- - {log_alert, boolean()} -

If set to false, error reports are not displayed.

- - {honor_cipher_order, boolean()} -

If set to true, use the server preference for cipher - selection. If set to false (the default), use the client - preference.

- - {sni_hosts, [{hostname(), [ssl_option()]}]} -

If the server receives a SNI (Server Name Indication) from the client - matching a host listed in the sni_hosts option, the specific options for - that host will override previously specified options. - - The option sni_fun, and sni_hosts are mutually exclusive.

- - {sni_fun, SNIfun::fun()} -

If the server receives a SNI (Server Name Indication) from the client, - the given function will be called to retrieve [ssl_option()] for the indicated server. - These options will be merged into predefined [ssl_option()]. - - The function should be defined as: - fun(ServerName :: string()) -> [ssl_option()] - and can be specified as a fun or as named fun module:function/1 - - The option sni_fun, and sni_hosts are mutually exclusive.

- - {client_renegotiation, boolean()} - In protocols that support client-initiated renegotiation, the cost - of resources of such an operation is higher for the server than the - client. This can act as a vector for denial of service attacks. The SSL - application already takes measures to counter-act such attempts, - but client-initiated renegotiation can be strictly disabled by setting - this option to false. The default value is true. - Note that disabling renegotiation can result in long-lived connections - becoming unusable due to limits on the number of messages the underlying - cipher suite can encipher. - - - {honor_cipher_order, boolean()} - If true, use the server's preference for cipher selection. If false - (the default), use the client's preference. - - {honor_ecc_order, boolean()} - If true, use the server's preference for ECC curve selection. If false - (the default), use the client's preference. - - - {signature_algs, [{hash(), ecdsa | rsa | dsa}]} -

The algorithms specified by - this option will be the ones accepted by the server in a signature algorithm - negotiation, introduced in TLS-1.2. The algorithms will also be offered to the client if a - client certificate is requested. For more details see the corresponding client option. -

- -
-
- -
- General + + +

Path to a file containing PEM-encoded CA + certificates. The CA certificates are used to build the server + certificate chain and for client authentication. The CAs are + also used in the list of acceptable client CAs passed to the + client when a certificate is requested. Can be omitted if + there is no need to verify the client and if there are no + intermediate CAs for the server certificate.

+
+
+ + + +

The DER-encoded Diffie-Hellman parameters. If + specified, it overrides option dhfile.

+
+
+ + + +

Path to a file containing PEM-encoded Diffie Hellman + parameters to be used by the server if a cipher suite using + Diffie Hellman key exchange is negotiated. If not specified, + default parameters are used.

+
+
-

When an TLS/DTLS socket is in active mode (the default), data from the - socket is delivered to the owner of the socket in the form of - messages:

- -

{ssl, Socket, Data}

-

{ssl_closed, Socket}

-

{ssl_error, Socket, Reason}

-
+ + +

A server only does x509-path validation in mode + verify_peer, as it then sends a certificate request to + the client (this message is not sent if the verify option is + verify_none). You can then also want to specify option + fail_if_no_peer_cert.

+
+
+ + + +

Used together with {verify, verify_peer} by an + TLS/DTLS server. If set to true, the server fails if + the client does not have a certificate to send, that is, sends + an empty certificate. If set to false, it fails only if + the client sends an invalid certificate (an empty certificate + is considered valid). Defaults to false.

+
+
+ + + +

The boolean value true specifies that the server will + agree to reuse sessions. Setting it to false will result in an empty + session table, that is no sessions will be reused. + See also option reuse_session +

+
+
+ + + +

Enables the TLS/DTLS server to have a local policy + for deciding if a session is to be reused or not. Meaningful + only if reuse_sessions is set to true. + SuggestedSessionId is a binary(), + PeerCert is a DER-encoded certificate, + Compression is an enumeration integer, and + CipherSuite is of type ciphersuite().

+
+
+ + + + +

Indicates the server will try to perform + Application-Layer Protocol Negotiation (ALPN).

+ +

The list of protocols is in order of preference. The + protocol negotiated will be the first in the list that + matches one of the protocols advertised by the client. If no + protocol matches, the server will fail the connection with a + "no_application_protocol" alert.

+ +

The negotiated protocol can be retrieved using the + negotiated_protocol/1 function.

+
+
+ + + +

List of protocols to send to the client if the client + indicates that it supports the Next Protocol extension. The + client can select a protocol that is not on this list. The + list of protocols must not contain an empty binary. If the + server negotiates a Next Protocol, it can be accessed using + the negotiated_next_protocol/1 method.

+
+
+ + + + +

Specifies the server identity hint, which the server presents to + the client.

+
+
+ + + + +

If set to true, use the server preference for cipher + selection. If set to false (the default), use the client + preference.

+
+
+ + + +

If the server receives a SNI (Server Name Indication) from the client + matching a host listed in the sni_hosts option, the specific options for + that host will override previously specified options. + + The option sni_fun, and sni_hosts are mutually exclusive.

+
+
+ + + + +

If the server receives a SNI (Server Name Indication) + from the client, the given function will be called to + retrieve [server_option()] for the indicated server. + These options will be merged into predefined + [server_option()] list. + + The function should be defined as: + fun(ServerName :: string()) -> [server_option()] + and can be specified as a fun or as named fun module:function/1 + + The option sni_fun, and sni_hosts are mutually exclusive.

+
+
+ + + +

In protocols that support client-initiated + renegotiation, the cost of resources of such an operation is + higher for the server than the client. This can act as a + vector for denial of service attacks. The SSL application + already takes measures to counter-act such attempts, but + client-initiated renegotiation can be strictly disabled by + setting this option to false. The default value is + true. Note that disabling renegotiation can result in + long-lived connections becoming unusable due to limits on the + number of messages the underlying cipher suite can + encipher.

+
+
+ + + +

If true, use the server's preference for cipher + selection. If false (the default), use the client's + preference.

+
+
+ + + +

If true, use the server's preference for ECC curve + selection. If false (the default), use the client's + preference.

+
+
+ + + +

The algorithms specified by this option will be the + ones accepted by the server in a signature algorithm + negotiation, introduced in TLS-1.2. The algorithms will also + be offered to the client if a client certificate is + requested. For more details see the corresponding client + option. +

+
+
+ + + -

A Timeout argument specifies a time-out in milliseconds. The - default value for argument Timeout is infinity.

-
- append_cipher_suites(Deferred, Suites) -> ciphers() - Deferred = ciphers() | cipher_filters() - Suites = ciphers() + Deferred = ciphers() | + cipher_filters() + Suites = ciphers()

Make Deferred suites become the least preferred suites, that is put them at the end of the cipher suite list @@ -922,7 +1095,7 @@ fun(srp, Username :: string(), UserState :: term()) -> all supported cipher suites. Supported = default | all | anonymous - Version = protocol_version() + Version = protocol_version()

Returns all default or all supported (except anonymous), or all anonymous cipher suites for a @@ -932,9 +1105,15 @@ fun(srp, Username :: string(), UserState :: term()) -> eccs() -> - eccs(protocol_version()) -> [named_curve()] + eccs(Version) -> NamedCurves Returns a list of supported ECCs. + + Version = protocol_version() + NamedCurves = [named_curve()] + + +

Returns a list of supported ECCs. eccs() is equivalent to calling eccs(Protocol) with all supported protocols and then deduplicating the output.

@@ -954,39 +1133,46 @@ fun(srp, Username :: string(), UserState :: term()) ->
- connect(Socket, SslOptions) -> - connect(Socket, SslOptions, Timeout) -> {ok, SslSocket} | {ok, SslSocket, Ext} + connect(Socket, Options) -> + connect(Socket, Options, Timeout) -> {ok, SslSocket} | {ok, SslSocket, Ext} | {error, Reason} Upgrades a gen_tcp, or equivalent, connected socket to an TLS socket. - Socket = socket() - SslOptions = [{handshake, hello| full} | ssl_option()] - Timeout = integer() | infinity - SslSocket = sslsocket() + Socket = socket() + Options = [client_option()] + Timeout = timeout() + SslSocket = sslsocket() Ext = hello_extensions() - Reason = term() + Reason = closed | timeout | error_alert()

Upgrades a gen_tcp, or equivalent, connected socket to an TLS socket, that is, performs the client-side TLS handshake.

-

If the option verify is set to verify_peer - the option server_name_indication shall also be specified, - if it is not no Server Name Indication extension will be sent, - and public_key:pkix_verify_hostname/2 - will be called with the IP-address of the connection as ReferenceID, which is proably not what you want.

+

If the option verify is set to + verify_peer the option server_name_indication + shall also be specified, if it is not no Server Name + Indication extension will be sent, and public_key:pkix_verify_hostname/2 + will be called with the IP-address of the connection as + ReferenceID, which is proably not what you want.

If the option {handshake, hello} is used the handshake is paused after receiving the server hello message and the success response is {ok, SslSocket, Ext} - instead of {ok, SslSocket}. Thereafter the handshake is continued or - canceled by calling + instead of {ok, SslSocket}. Thereafter the handshake + is continued or canceled by calling handshake_continue/3 or handshake_cancel/1. + marker="#handshake_cancel-1">handshake_cancel/1.

+

If the option active is set to once or true the + process owning the sslsocket will receive messages of type + active_msgs() +

@@ -996,19 +1182,19 @@ fun(srp, Username :: string(), UserState :: term()) -> {ok, SslSocket}| {ok, SslSocket, Ext} | {error, Reason} Opens an TLS/DTLS connection to Host, Port. - Host = host() - Port = integer() - Options = [option()] - Timeout = integer() | infinity - SslSocket = sslsocket() - Reason = term() + Host = host() + Port = inet:port_number() + Options = [client_option()] + Timeout = timeout() + SslSocket = sslsocket() + Reason = closed | timeout | error_alert()

Opens an TLS/DTLS connection to Host, Port.

When the option verify is set to verify_peer the check public_key:pkix_verify_hostname/2 will be performed in addition to the usual x509-path validation checks. If the check fails the error {bad_cert, hostname_check_failed} will - be propagated to the path validation fun verify_fun, where it is possible to do customized + be propagated to the path validation fun verify_fun, where it is possible to do customized checks by using the full possibilities of the public_key:pkix_verify_hostname/3 API. When the option server_name_indication is provided, its value (the DNS name) will be used as ReferenceID @@ -1030,6 +1216,11 @@ fun(srp, Username :: string(), UserState :: term()) -> handshake_continue/3 or handshake_cancel/1.

+ +

If the option active is set to once or true the + process owning the sslsocket will receive messages of type + active_msgs() +

@@ -1037,7 +1228,7 @@ fun(srp, Username :: string(), UserState :: term()) -> close(SslSocket) -> ok | {error, Reason} Closes an TLS/DTLS connection. - SslSocket = sslsocket() + SslSocket = sslsocket() Reason = term()

Closes an TLS/DTLS connection.

@@ -1048,7 +1239,7 @@ fun(srp, Username :: string(), UserState :: term()) -> close(SslSocket, How) -> ok | {ok, port()} | {error, Reason} Closes an TLS connection. - SslSocket = sslsocket() + SslSocket = sslsocket() How = timeout() | {NewController::pid(), timeout()} Reason = term() @@ -1065,7 +1256,7 @@ fun(srp, Username :: string(), UserState :: term()) -> Assigns a new controlling process to the TLS/DTLS socket. - SslSocket = sslsocket() + SslSocket = sslsocket() NewOwner = pid() Reason = term() @@ -1081,7 +1272,7 @@ fun(srp, Username :: string(), UserState :: term()) -> Returns all the connection information. - SslSocket = sslsocket() + SslSocket = sslsocket() Item = protocol | selected_cipher_suite | sni_hostname | ecc | session_id | atom() Meaningful atoms, not specified above, are the ssl option names. Result = [{Item::atom(), Value::term()}] @@ -1102,7 +1293,7 @@ fun(srp, Username :: string(), UserState :: term()) -> Returns the requested connection information. - SslSocket = sslsocket() + SslSocket = sslsocket() Items = [Item] Item = protocol | cipher_suite | sni_hostname | ecc | session_id | client_random | server_random | master_secret | atom() @@ -1122,8 +1313,8 @@ fun(srp, Username :: string(), UserState :: term()) -> filter_cipher_suites(Suites, Filters) -> ciphers() - Suites = ciphers() - Filters = cipher_filters() + Suites = ciphers() + Filters = cipher_filters()

Removes cipher suites if any of the filter functions returns false for any part of the cipher suite. This function @@ -1149,7 +1340,7 @@ fun(srp, Username :: string(), UserState :: term()) -> {ok, [socketoption()]} | {error, Reason} Gets the values of the specified options. - Socket = sslsocket() + Socket = sslsocket() OptionNames = [atom()] @@ -1165,7 +1356,7 @@ fun(srp, Username :: string(), UserState :: term()) -> {ok, OptionValues} | {error, inet:posix()} Get one or more statistic options for a socket - SslSocket = sslsocket() + SslSocket = sslsocket() OptionNames = [atom()] OptionValues = [{inet:stat_option(), integer()}] @@ -1180,27 +1371,32 @@ fun(srp, Username :: string(), UserState :: term()) -> handshake(HsSocket, Timeout) -> {ok, SslSocket} | {error, Reason} Performs server-side SSL/TLS handshake. - HsSocket = SslSocket = sslsocket() - Timeout = integer() - Reason = term() + HsSocket = SslSocket = sslsocket() + Timeout = timeout() + Reason = closed | timeout | error_alert()

Performs the SSL/TLS/DTLS server-side handshake.

Returns a new TLS/DTLS socket if the handshake is successful.

+ +

If the option active is set to once or true the + process owning the sslsocket will receive messages of type + active_msgs() +

- handshake(Socket, SslOptions) -> - handshake(Socket, SslOptions, Timeout) -> {ok, SslSocket} | {ok, SslSocket, Ext} | {error, Reason} + handshake(Socket, Options) -> + handshake(Socket, Options, Timeout) -> {ok, SslSocket} | {ok, SslSocket, Ext} | {error, Reason} Performs server-side SSL/TLS/DTLS handshake. - Socket = socket() | sslsocket() - SslSocket = sslsocket() + Socket = socket() | socket() + SslSocket = sslsocket() Ext = hello_extensions() - SslOptions = [{handshake, hello| full} | ssl_option()] - Timeout = integer() - Reason = term() + Options = [server_option()] + Timeout = timeout() + Reason = closed | timeout | error_alert()

If Socket is a ordinary socket(): upgrades a gen_tcp, @@ -1212,7 +1408,8 @@ fun(srp, Username :: string(), UserState :: term()) -> is undefined.

-

If Socket is an sslsocket(): provides extra SSL/TLS/DTLS +

If Socket is an + sslsocket() : provides extra SSL/TLS/DTLS options to those specified in listen/2 and then performs the SSL/TLS/DTLS handshake. Returns a new TLS/DTLS socket if the handshake is successful.

@@ -1226,6 +1423,12 @@ fun(srp, Username :: string(), UserState :: term()) -> handshake_continue/3 or handshake_cancel/1.

+ +

If the option active is set to once or true the + process owning the sslsocket will receive messages of type + active_msgs() +

+
@@ -1233,7 +1436,7 @@ fun(srp, Username :: string(), UserState :: term()) -> handshake_cancel(SslSocket) -> ok Cancel handshake with a fatal alert - SslSocket = sslsocket() + SslSocket = sslsocket()

Cancel the handshake with a fatal USER_CANCELED alert.

@@ -1241,14 +1444,14 @@ fun(srp, Username :: string(), UserState :: term()) -> - handshake_continue(HsSocket, SSLOptions) -> {ok, SslSocket} | {error, Reason} - handshake_continue(HsSocket, SSLOptions, Timeout) -> {ok, SslSocket} | {error, Reason} + handshake_continue(HsSocket, Options) -> {ok, SslSocket} | {error, Reason} + handshake_continue(HsSocket, Options, Timeout) -> {ok, SslSocket} | {error, Reason} Continue the SSL/TLS handshake. - HsSocket = SslSocket = sslsocket() - SslOptions = [ssl_option()] - Timeout = integer() - Reason = term() + HsSocket = SslSocket = sslsocket() + Options = tls_option() + Timeout = timeout() + Reason = closed | timeout | error_alert()

Continue the SSL/TLS handshake possiby with new, additional or changed options.

@@ -1260,9 +1463,9 @@ fun(srp, Username :: string(), UserState :: term()) -> {ok, ListenSocket} | {error, Reason} Creates an SSL listen socket. - Port = integer() - Options = options() - ListenSocket = sslsocket() + Port = inet:port_number() + Options = [server_option()] + ListenSocket = sslsocket()

Creates an SSL listen socket.

@@ -1273,7 +1476,7 @@ fun(srp, Username :: string(), UserState :: term()) -> negotiated_protocol(SslSocket) -> {ok, Protocol} | {error, protocol_not_negotiated} Returns the protocol negotiated through ALPN or NPN extensions. - SslSocket = sslsocket() + SslSocket = sslsocket() Protocol = binary() @@ -1287,7 +1490,7 @@ fun(srp, Username :: string(), UserState :: term()) -> peercert(SslSocket) -> {ok, Cert} | {error, Reason} Returns the peer certificate. - SslSocket = sslsocket() + SslSocket = sslsocket() Cert = binary() @@ -1303,9 +1506,9 @@ fun(srp, Username :: string(), UserState :: term()) -> {error, Reason} Returns the peer address and port. - SslSocket = sslsocket() + SslSocket = sslsocket() Address = ipaddress() - Port = integer() + Port = inet:port_number()

Returns the address and port number of the peer.

@@ -1316,8 +1519,9 @@ fun(srp, Username :: string(), UserState :: term()) -> prepend_cipher_suites(Preferred, Suites) -> ciphers() - Preferred = ciphers() | cipher_filters() - Suites = ciphers() + Preferred = ciphers() | + cipher_filters() + Suites = ciphers()

Make Preferred suites become the most preferred suites that is put them at the head of the cipher suite list @@ -1332,7 +1536,7 @@ fun(srp, Username :: string(), UserState :: term()) -> prf(Socket, Secret, Label, Seed, WantedLength) -> {ok, binary()} | {error, reason()} Uses a session Pseudo-Random Function to generate key material. - Socket = sslsocket() + Socket = sslsocket() Secret = binary() | master_secret Label = binary() Seed = [binary() | prf_random()] @@ -1354,9 +1558,9 @@ fun(srp, Username :: string(), UserState :: term()) -> Reason} Receives data on a socket. - SslSocket = sslsocket() + SslSocket = sslsocket() Length = integer() - Timeout = integer() + Timeout = timeout() Data = [char()] | binary() @@ -1379,7 +1583,7 @@ fun(srp, Username :: string(), UserState :: term()) -> renegotiate(SslSocket) -> ok | {error, Reason} Initiates a new handshake. - SslSocket = sslsocket() + SslSocket = sslsocket()

Initiates a new handshake. A notable return value is {error, renegotiation_rejected} indicating that the peer @@ -1392,7 +1596,7 @@ fun(srp, Username :: string(), UserState :: term()) -> send(SslSocket, Data) -> ok | {error, Reason} Writes data to a socket. - SslSocket = sslsocket() + SslSocket = sslsocket() Data = iodata() @@ -1406,8 +1610,8 @@ fun(srp, Username :: string(), UserState :: term()) -> setopts(SslSocket, Options) -> ok | {error, Reason} Sets socket options. - SslSocket = sslsocket() - Options = [socketoption]() + SslSocket = sslsocket() + Options = [socket_option()]

Sets options according to Options for socket @@ -1419,7 +1623,7 @@ fun(srp, Username :: string(), UserState :: term()) -> shutdown(SslSocket, How) -> ok | {error, Reason} Immediately closes a socket. - SslSocket = sslsocket() + SslSocket = sslsocket() How = read | write | read_write Reason = reason() @@ -1438,9 +1642,9 @@ fun(srp, Username :: string(), UserState :: term()) -> ssl_accept(SslSocket, Timeout) -> ok | {error, Reason} Performs server-side SSL/TLS handshake. - SslSocket = sslsocket() - Timeout = integer() - Reason = term() + SslSocket = sslsocket() + Timeout = timeout() + Reason = closed | timeout | error_alert()

Deprecated in OTP 21, use handshake/[1,2] instead.

@@ -1449,14 +1653,14 @@ fun(srp, Username :: string(), UserState :: term()) ->
- ssl_accept(Socket, SslOptions) -> - ssl_accept(Socket, SslOptions, Timeout) -> {ok, Socket} | ok | {error, Reason} + ssl_accept(Socket, Options) -> + ssl_accept(Socket, Options, Timeout) -> {ok, Socket} | ok | {error, Reason} Performs server-side SSL/TLS/DTLS handshake. - Socket = socket() | sslsocket() - SslOptions = [ssl_option()] - Timeout = integer() - Reason = term() + Socket = socket() | sslsocket() + Options = [server_option()] + Timeout = timeout() + Reason = closed | timeout | error_alert()

Deprecated in OTP 21, use handshake/[2,3] instead.

@@ -1469,9 +1673,9 @@ fun(srp, Username :: string(), UserState :: term()) -> {error, Reason} Returns the local address and port. - SslSocket = sslsocket() - Address = ipaddress() - Port = integer() + SslSocket = sslsocket() + Address = ip_address() + Port = inet:port_number()

Returns the local address and port number of socket @@ -1504,7 +1708,7 @@ fun(srp, Username :: string(), UserState :: term()) -> suite_to_str(CipherSuite) -> String Returns the string representation of a cipher suite. - CipherSuite = erl_cipher_suite() + CipherSuite = erl_cipher_suite() String = string() @@ -1519,8 +1723,8 @@ fun(srp, Username :: string(), UserState :: term()) -> Accepts an incoming connection and prepares for ssl_accept. - ListenSocket = SslSocket = sslsocket() - Timeout = integer() + ListenSocket = SslSocket = sslsocket() + Timeout = timeout() Reason = reason() -- cgit v1.2.3