.TH ssl 3erl "ssl 10.9.1.3" "Ericsson AB" "Erlang Module Definition" .SH NAME ssl \- Interface Functions for Secure Socket Layer .SH DESCRIPTION .LP This module contains interface functions for the TLS/DTLS protocol\&. For detailed information about the supported standards see ssl(7)\&. .SH DATA TYPES .SS Types used in TLS/DTLS .nf \fBsocket()\fR\& = gen_tcp:socket() .br .fi .nf \fBsslsocket()\fR\& = any() .br .fi .RS .LP An opaque reference to the TLS/DTLS connection, may be used for equality matching\&. .RE .nf \fBtls_option()\fR\& = tls_client_option() | tls_server_option() .br .fi .nf \fBtls_client_option()\fR\& = .br client_option() | .br common_option() | .br socket_option() | .br transport_option() .br .fi .nf \fBtls_server_option()\fR\& = .br server_option() | .br common_option() | .br socket_option() | .br transport_option() .br .fi .nf \fBsocket_option()\fR\& = .br gen_tcp:connect_option() | .br gen_tcp:listen_option() | .br gen_udp:option() .br .fi .RS .LP The default socket options are \fI[{mode,list},{packet, 0},{header, 0},{active, true}]\fR\&\&. .LP For valid options, see the inet(3erl), gen_tcp(3erl) and gen_udp(3erl) manual pages in Kernel\&. Note that stream oriented options such as packet are only relevant for TLS and not DTLS .RE .nf \fBactive_msgs()\fR\& = .br {ssl, sslsocket(), Data :: binary() | list()} | .br {ssl_closed, sslsocket()} | .br {ssl_error, sslsocket(), Reason :: any()} | .br {ssl_passive, sslsocket()} .br .fi .RS .LP When a 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\&. .LP The \fIssl_passive\fR\& message is sent only when the socket is in \fI{active, N}\fR\& mode and the counter dropped to 0\&. It indicates that the socket has transitioned to passive (\fI{active, false}\fR\&) mode\&. .RE .nf \fBtransport_option()\fR\& = .br {cb_info, .br {CallbackModule :: atom(), .br DataTag :: atom(), .br ClosedTag :: atom(), .br ErrTag :: atom()}} | .br {cb_info, .br {CallbackModule :: atom(), .br DataTag :: atom(), .br ClosedTag :: atom(), .br ErrTag :: atom(), .br PassiveTag :: atom()}} .br .fi .RS .LP Defaults to \fI{gen_tcp, tcp, tcp_closed, tcp_error, tcp_passive}\fR\& for TLS (for backward compatibility a four tuple will be converted to a five tuple with the last element "second_element"_passive) and \fI{gen_udp, udp, udp_closed, udp_error}\fR\& for DTLS (might also be changed to five tuple in the future)\&. 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 \fIgen_tcp\fR\&, and have functions corresponding to \fIinet:setopts/2\fR\&, \fIinet:getopts/2\fR\&, \fIinet:peername/1\fR\&, \fIinet:sockname/1\fR\&, and \fIinet:port/1\fR\&\&. The callback \fIgen_tcp\fR\& is treated specially and calls \fIinet\fR\& directly\&. For DTLS this feature must be considered experimental\&. .RE .nf \fBhost()\fR\& = hostname() | ip_address() .br .fi .nf \fBhostname()\fR\& = string() .br .fi .nf \fBip_address()\fR\& = inet:ip_address() .br .fi .nf \fBprotocol_version()\fR\& = tls_version() | dtls_version() .br .fi .nf \fBtls_version()\fR\& = \&'tlsv1\&.2\&' | \&'tlsv1\&.3\&' | tls_legacy_version() .br .fi .nf \fBdtls_version()\fR\& = \&'dtlsv1\&.2\&' | dtls_legacy_version() .br .fi .nf \fBtls_legacy_version()\fR\& = tlsv1 | \&'tlsv1\&.1\&' .br .fi .nf \fBdtls_legacy_version()\fR\& = dtlsv1 .br .fi .nf \fBprf_random()\fR\& = client_random | server_random .br .fi .nf \fBverify_type()\fR\& = verify_none | verify_peer .br .fi .nf \fBciphers()\fR\& = [erl_cipher_suite()] | string() .br .fi .nf \fBerl_cipher_suite()\fR\& = .br #{key_exchange := kex_algo(), .br cipher := cipher(), .br mac := hash() | aead, .br prf := hash() | default_prf} .br .fi .nf \fBcipher()\fR\& = .br aes_128_cbc | aes_256_cbc | aes_128_gcm | aes_256_gcm | .br aes_128_ccm | aes_256_ccm | aes_128_ccm_8 | aes_256_ccm_8 | .br chacha20_poly1305 | .br legacy_cipher() .br .fi .nf \fBlegacy_cipher()\fR\& = rc4_128 | des_cbc | \&'3des_ede_cbc\&' .br .fi .nf \fBcipher_filters()\fR\& = .br [{key_exchange | cipher | mac | prf, algo_filter()}] .br .fi .nf \fBhash()\fR\& = sha | sha2() | legacy_hash() .br .fi .nf \fBsha2()\fR\& = sha224 | sha256 | sha384 | sha512 .br .fi .nf \fBlegacy_hash()\fR\& = md5 .br .fi .nf \fBold_cipher_suite()\fR\& = .br {kex_algo(), cipher(), hash()} | .br {kex_algo(), cipher(), hash() | aead, hash()} .br .fi .nf \fBsign_algo()\fR\& = rsa | dsa | ecdsa | eddsa .br .fi .nf \fBsign_scheme()\fR\& = .br eddsa_ed25519 | eddsa_ed448 | ecdsa_secp256r1_sha256 | .br ecdsa_secp384r1_sha384 | ecdsa_secp521r1_sha512 | .br rsassa_pss_scheme() | .br sign_scheme_legacy() .br .fi .nf \fBrsassa_pss_scheme()\fR\& = .br rsa_pss_rsae_sha256 | rsa_pss_rsae_sha384 | .br rsa_pss_rsae_sha512 | rsa_pss_pss_sha256 | .br rsa_pss_pss_sha384 | rsa_pss_pss_sha512 .br .fi .nf \fBsign_scheme_legacy()\fR\& = .br rsa_pkcs1_sha256 | rsa_pkcs1_sha384 | rsa_pkcs1_sha512 | .br rsa_pkcs1_sha1 | ecdsa_sha1 .br .fi .nf \fBgroup()\fR\& = .br secp256r1 | secp384r1 | secp521r1 | ffdhe2048 | ffdhe3072 | .br ffdhe4096 | ffdhe6144 | ffdhe8192 .br .fi .nf \fBkex_algo()\fR\& = .br rsa | dhe_rsa | dhe_dss | ecdhe_ecdsa | ecdh_ecdsa | .br ecdh_rsa | srp_rsa | srp_dss | psk | dhe_psk | rsa_psk | .br dh_anon | ecdh_anon | srp_anon | any .br .fi .nf \fBalgo_filter()\fR\& = .br fun((kex_algo() | cipher() | hash() | aead | default_prf) -> .br true | false) .br .fi .nf \fBnamed_curve()\fR\& = .br sect571r1 | sect571k1 | secp521r1 | brainpoolP512r1 | .br sect409k1 | sect409r1 | brainpoolP384r1 | secp384r1 | .br sect283k1 | sect283r1 | brainpoolP256r1 | secp256k1 | .br secp256r1 | sect239k1 | sect233k1 | sect233r1 | secp224k1 | .br secp224r1 | sect193r1 | sect193r2 | secp192k1 | secp192r1 | .br sect163k1 | sect163r1 | sect163r2 | secp160k1 | secp160r1 | .br secp160r2 .br .fi .nf \fBpsk_identity()\fR\& = string() .br .fi .nf \fBsrp_identity()\fR\& = {Username :: string(), Password :: string()} .br .fi .nf \fBsrp_param_type()\fR\& = .br srp_1024 | srp_1536 | srp_2048 | srp_3072 | srp_4096 | .br srp_6144 | srp_8192 .br .fi .nf \fBapp_level_protocol()\fR\& = binary() .br .fi .nf \fBprotocol_extensions()\fR\& = .br #{renegotiation_info => binary(), .br signature_algs => signature_algs(), .br alpn => app_level_protocol(), .br srp => binary(), .br next_protocol => app_level_protocol(), .br max_frag_enum => 1\&.\&.4, .br ec_point_formats => [0\&.\&.2], .br elliptic_curves => [public_key:oid()], .br sni => hostname()} .br .fi .nf \fBerror_alert()\fR\& = .br {tls_alert, {tls_alert(), Description :: string()}} .br .fi .nf \fBtls_alert()\fR\& = .br close_notify | unexpected_message | bad_record_mac | .br record_overflow | handshake_failure | bad_certificate | .br unsupported_certificate | certificate_revoked | .br certificate_expired | certificate_unknown | .br illegal_parameter | unknown_ca | access_denied | .br decode_error | decrypt_error | export_restriction | .br protocol_version | insufficient_security | internal_error | .br inappropriate_fallback | user_canceled | no_renegotiation | .br unsupported_extension | certificate_unobtainable | .br unrecognized_name | bad_certificate_status_response | .br bad_certificate_hash_value | unknown_psk_identity | .br no_application_protocol .br .fi .nf \fBreason()\fR\& = any() .br .fi .nf \fBbloom_filter_window_size()\fR\& = integer() .br .fi .nf \fBbloom_filter_hash_functions()\fR\& = integer() .br .fi .nf \fBbloom_filter_bits()\fR\& = integer() .br .fi .nf \fBclient_session_tickets()\fR\& = disabled | manual | auto .br .fi .nf \fBserver_session_tickets()\fR\& = disabled | stateful | stateless .br .fi .SS TLS/DTLS OPTION DESCRIPTIONS - COMMON for SERVER and CLIENT .nf \fBcommon_option()\fR\& = .br {protocol, protocol()} | .br {handshake, handshake_completion()} | .br {cert, cert() | [cert()]} | .br {certfile, cert_pem()} | .br {key, key()} | .br {keyfile, key_pem()} | .br {password, key_pem_password()} | .br {certs_keys, certs_keys()} | .br {ciphers, cipher_suites()} | .br {eccs, [named_curve()]} | .br {signature_algs, signature_algs()} | .br {signature_algs_cert, sign_schemes()} | .br {supported_groups, supported_groups()} | .br {secure_renegotiate, secure_renegotiation()} | .br {keep_secrets, keep_secrets()} | .br {depth, allowed_cert_chain_length()} | .br {verify_fun, custom_verify()} | .br {crl_check, crl_check()} | .br {crl_cache, crl_cache_opts()} | .br {max_handshake_size, handshake_size()} | .br {partial_chain, root_fun()} | .br {versions, protocol_versions()} | .br {user_lookup_fun, custom_user_lookup()} | .br {log_level, logging_level()} | .br {log_alert, log_alert()} | .br {hibernate_after, hibernate_after()} | .br {padding_check, padding_check()} | .br {beast_mitigation, beast_mitigation()} | .br {ssl_imp, ssl_imp()} | .br {session_tickets, session_tickets()} | .br {key_update_at, key_update_at()} | .br {receiver_spawn_opts, spawn_opts()} | .br {sender_spawn_opts, spawn_opts()} .br .fi .nf \fBprotocol()\fR\& = tls | dtls .br .fi .RS .LP Choose TLS or DTLS protocol for the transport layer security\&. Defaults to \fItls\fR\&\&. For DTLS other transports than UDP are not yet supported\&. .RE .nf \fBhandshake_completion()\fR\& = hello | full .br .fi .RS .LP Defaults to \fIfull\fR\&\&. 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 .RE .nf \fBcert()\fR\& = public_key:der_encoded() .br .fi .RS .LP The DER-encoded user certificate\&. Note that the cert option may also be a list of DER-encoded certificates where the first one is the user certificate, and the rest of the certificates constitutes the certificate chain\&. For maximum interoperability the certificates in the chain should be in the correct order, the chain will be sent as is to the peer\&. If chain certificates are not provided, certificates from client_cacerts(), server_cacerts(), or client_cafile(), server_cafile() are used to construct the chain\&. If this option is supplied, it overrides option \fIcertfile\fR\&\&. .RE .nf \fBcert_pem()\fR\& = file:filename() .br .fi .RS .LP Path to a file containing the user certificate on PEM format or possible several certificates where the first one is the user certificate and the rest of the certificates constitutes the certificate chain\&. For more details see cert(), .RE .nf \fBkey()\fR\& = .br {\&'RSAPrivateKey\&' | \&'DSAPrivateKey\&' | \&'ECPrivateKey\&' | .br \&'PrivateKeyInfo\&', .br public_key:der_encoded()} | .br #{algorithm := rsa | dss | ecdsa, .br engine := crypto:engine_ref(), .br key_id := crypto:key_id(), .br password => crypto:password()} .br .fi .RS .LP The DER-encoded user\&'s private key or a map referring to a crypto engine and its key reference that optionally can be password protected, see also crypto:engine_load/3 and Crypto\&'s Users Guide\&. If this option is supplied, it overrides option \fIkeyfile\fR\&\&. .RE .nf \fBkey_pem()\fR\& = file:filename() .br .fi .RS .LP 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 \fIcertfile\fR\&\&. .RE .nf \fBkey_pem_password()\fR\& = iodata() | fun(() -> iodata()) .br .fi .RS .LP String containing the user\&'s password or a function returning same type\&. Only used if the private keyfile is password-protected\&. .RE .nf \fBcerts_keys()\fR\& = [cert_key_conf()] .br .fi .RS .LP A list of a certificate (or possible a certificate and its chain) and the associated key of the certificate, that may be used to authenticate the client or the server\&. The certificate key pair that is considered best and matches negotiated parameters for the connection will be selected\&. Different signature algorithms are prioritized in the order \fI eddsa, ecdsa, rsa_pss_pss, rsa and dsa \fR\&\&. If more than one key is supplied for the same signing algorithm (which is probably an unusual use case) they will prioritized by strength unless it is a so called \fIengine key\fR\& that will be favoured over other keys\&. As engine keys cannot be inspected, supplying more than one engine key will make no sense\&. This offers flexibility to for instance configure a newer certificate that is expected to be used in most cases and an older but acceptable certificate that will only be used to communicate with legacy systems\&. Note that there is a trade off between the induced overhead and the flexibility so alternatives should be chosen for good reasons\&. If the \fIcerts_keys\fR\& option is specified it overrides all single certificate and key options\&. For examples see the Users Guide .LP .RS -4 .B Note: .RE \fIeddsa\fR\& certificates are only supported by TLS-1\&.3 that does not support \fIdsa\fR\& certificates\&. \fIrsa_pss_pss\fR\& (RSA certificates using Probabilistic Signature Scheme) are supported in TLS-1\&.2 and TLS-1\&.3, but some TLS-1\&.2 implementations may not support \fIrsa_pss_pss\fR\&\&. .RE .nf \fBcert_key_conf()\fR\& = .br #{cert => cert(), .br key => key(), .br certfile => cert_pem(), .br keyfile => key_pem(), .br password => key_pem_password()} .br .fi .RS .LP A certificate (or possibly a certificate and its chain) and its associated key on one of the possible formats\&. For the PEM file format there may also be a password associated with the file containg the key\&. .RE .nf \fBcipher_suites()\fR\& = ciphers() .br .fi .RS .LP A list of cipher suites that should be supported .LP The function ssl:cipher_suites/2 can be used to find all cipher suites that are supported by default and all cipher suites that may be configured\&. .LP If you compose your own \fIcipher_suites()\fR\& make sure they are filtered for cryptolib support ssl:filter_cipher_suites/2 Additionally the functions ssl:append_cipher_suites/2 , ssl:prepend_cipher_suites/2, ssl:suite_to_str/1, ssl:str_to_suite/1, and ssl:suite_to_openssl_str/1 also exist to help creating customized cipher suite lists\&. .LP .RS -4 .B Note: .RE Note that TLS-1\&.3 and TLS-1\&.2 cipher suites are not overlapping sets of cipher suites so to support both these versions cipher suites from both versions need to be included\&. Also if the supplied list does not comply with the configured versions or cryptolib so that the list becomes empty, this option will fallback on its appropriate default value for the configured versions\&. .LP Non-default cipher suites including anonymous cipher suites (PRE TLS-1\&.3) are supported for interop/testing purposes and may be used by adding them to your cipher suite list\&. Note that they must also be supported/enabled by the peer to actually be used\&. .RE .nf \fBsignature_algs()\fR\& = [{hash(), sign_algo()} | sign_scheme()] .br .fi .RS .LP Explicitly list acceptable signature algorithms for certificates and handshake messages in the preferred order\&. The client will send its list as the client hello \fIsignature_algorithm\fR\& extension introduced in TLS-1\&.2, see Section 7\&.4\&.1\&.4\&.1 in RFC 5246\&. Previously these algorithms where implicitly chosen and partly derived from the cipher suite\&. .LP In TLS-1\&.2 a somewhat more explicit negotiation is made possible using a list of {hash(), sign_algo()} pairs\&. .LP In TLS-1\&.3 these algorithm pairs are replaced by so called signature schemes sign_scheme() and completely decoupled from the cipher suite\&. .LP Signature algorithms used for certificates may be overridden by the signature schemes (algorithms) supplied by the \fIsignature_algs_cert\fR\& option\&. .LP TLS-1\&.2 default is Default_TLS_12_Alg_Pairs interleaved with rsa_pss_schemes since ssl-11\&.0 (OTP-25) pss_pss is prefered over pss_rsae that is prefered over rsa .LP \fIDefault_TLS_12_Alg_Pairs =\fR\& .LP .nf [ %% SHA2 {sha512, ecdsa}, {sha512, rsa}, {sha384, ecdsa}, {sha384, rsa}, {sha256, ecdsa}, {sha256, rsa}, {sha224, ecdsa}, {sha224, rsa}, %% SHA {sha, ecdsa}, {sha, rsa}, {sha, dsa} ] .fi .LP Support for {md5, rsa} was removed from the the TLS-1\&.2 default in ssl-8\&.0 (OTP-22) .LP \fI rsa_pss_schemes =\fR\& .LP .nf [rsa_pss_pss_sha512, rsa_pss_pss_sha384, rsa_pss_pss_sha256, rsa_pss_rsae_sha512, rsa_pss_rsae_sha384, rsa_pss_rsae_sha256] .fi .LP \fI TLS_13_Legacy_Schemes =\fR\& .LP .nf [ %% Legacy algorithms only applicable to certificate signatures rsa_pkcs1_sha512, %% Corresponds to {sha512, rsa} rsa_pkcs1_sha384, %% Corresponds to {sha384, rsa} rsa_pkcs1_sha256, %% Corresponds to {sha256, rsa} ecdsa_sha1, %% Corresponds to {sha, ecdsa} rsa_pkcs1_sha1 %% Corresponds to {sha, rsa} ] .fi .LP \fI Default_TLS_13_Schemes =\fR\& .LP .nf [ %% EDDSA eddsa_ed25519, eddsa_ed448 %% ECDSA ecdsa_secp521r1_sha512, ecdsa_secp384r1_sha384, ecdsa_secp256r1_sha256] ++ %% RSASSA-PSS rsa_pss_schemes() .fi .LP EDDSA was made highest priority in ssl-11\&.0 (OTP-25) .LP TLS-1\&.3 default is .LP .nf Default_TLS_13_Schemes ++ Legacy_TLS_13_Schemes .fi .LP If both TLS-1\&.3 and TLS-1\&.2 are supported the default will be .LP .nf Default_TLS_13_Schemes ++ Default_TLS_12_Alg_Pairs .fi .LP so appropriate algorithms can be chosen for the negotiated version\&. .LP .RS -4 .B Note: .RE TLS-1\&.2 algorithms will not be negotiated for TLS-1\&.3, but TLS-1\&.3 RSASSA-PSS rsassa_pss_scheme() signature schemes may be negotiated also for TLS-1\&.2 from 24\&.1 (fully working from 24\&.1\&.3)\&. However if TLS-1\&.3 is negotiated when both TLS-1\&.3 and TLS-1\&.2 is supported using defaults, the corresponding TLS-1\&.2 algorithms to the TLS-1\&.3 legacy signature schemes will be considered as the legacy schemes and applied only to certificate signatures\&. .RE .nf \fBsign_schemes()\fR\& = [sign_scheme()] .br .fi .RS .LP Explicitly list acceptable signature schemes (algorithms) in the preferred order\&. Overrides the algorithms supplied in \fIsignature_algs\fR\& option for certificates\&. .LP In addition to the \fIsignature_algorithms\fR\& extension from TLS 1\&.2, TLS 1\&.3 (RFC 5246 Section 4\&.2\&.3) adds the \fIsignature_algorithms_cert\fR\& extension which enables having special requirements on the signatures used in the certificates that differs from the requirements on digital signatures as a whole\&. If this is not required this extension is not need\&. .LP The client will send a \fIsignature_algorithms_cert\fR\& extension (in the client hello message), if TLS version 1\&.2 (back-ported to TLS 1\&.2 in 24\&.1) or later is used, and the signature_algs_cert option is explicitly specified\&. By default, only the signature_algs extension is sent\&. .LP .RS -4 .B Note: .RE Note that supported signature schemes for TLS-1\&.2 are sign_scheme_legacy() and rsassa_pss_scheme() .RE .nf \fBsupported_groups()\fR\& = [group()] .br .fi .RS .LP TLS 1\&.3 introduces the "supported_groups" extension that is used for negotiating the Diffie-Hellman parameters in a TLS 1\&.3 handshake\&. Both client and server can specify a list of parameters that they are willing to use\&. .LP If it is not specified it will use a default list ([x25519, x448, secp256r1, secp384r1]) that is filtered based on the installed crypto library version\&. .RE .nf \fBsecure_renegotiation()\fR\& = boolean() .br .fi .RS .LP Specifies if to reject renegotiation attempt that does not live up to RFC 5746\&. By default \fIsecure_renegotiate\fR\& is set to \fItrue\fR\&, that is, secure renegotiation is enforced\&. If set to \fIfalse\fR\& secure renegotiation will still be used if possible, but it falls back to insecure renegotiation if the peer does not support RFC 5746\&. .RE .nf \fBallowed_cert_chain_length()\fR\& = integer() .br .fi .RS .LP 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 10\&. .RE .nf \fBcustom_verify()\fR\& = .br {Verifyfun :: function(), InitialUserState :: any()} .br .fi .RS .LP The verification fun is to be defined as follows: .LP .nf fun(OtpCert :: #'OTPCertificate'{}, Event, InitialUserState :: term()) -> {valid, UserState :: term()} | {fail, Reason :: term()} | {unknown, UserState :: term()}. fun(OtpCert :: #'OTPCertificate'{}, DerCert :: public_key:der_encoded(), Event, InitialUserState :: term()) -> {valid, UserState :: term()} | {fail, Reason :: term()} | {unknown, UserState :: term()}. Types: Event = {bad_cert, Reason :: atom() | {revoked, atom()}} | {extension, #'Extension'{}} | valid | valid_peer .fi .LP 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 \fIvalid_peer\fR\& or \fIvalid\fR\& as \fIEvent\fR\& argument to the verification fun\&. See the public_key User\&'s Guide for definition of \fI#\&'OTPCertificate\&'{}\fR\& and \fI#\&'Extension\&'{}\fR\&\&. .RS 2 .TP 2 * If the verify callback fun returns \fI{fail, Reason}\fR\&, the verification process is immediately stopped, an alert is sent to the peer, and the TLS/DTLS handshake terminates\&. .LP .TP 2 * If the verify callback fun returns \fI{valid, UserState}\fR\&, the verification process continues\&. .LP .TP 2 * If the verify callback fun always returns \fI{valid, UserState}\fR\&, the TLS/DTLS handshake does not terminate regarding verification failures and the connection is established\&. .LP .TP 2 * If called with an extension unknown to the user application, return value \fI{unknown, UserState}\fR\& is to be used\&. .RS 2 .LP Note that if the fun returns \fIunknown\fR\& for an extension marked as critical, validation will fail\&. .RE .LP .RE .LP Default option \fIverify_fun\fR\& in \fIverify_peer mode\fR\&: .LP .nf {fun(_,{bad_cert, _} = Reason, _) -> {fail, Reason}; (_,{extension, _}, UserState) -> {unknown, UserState}; (_, valid, UserState) -> {valid, UserState}; (_, valid_peer, UserState) -> {valid, UserState} end, []} .fi .LP Default option \fIverify_fun\fR\& in mode \fIverify_none\fR\&: .LP .nf {fun(_,{bad_cert, _}, UserState) -> {valid, UserState}; (_,{extension, #'Extension'{critical = true}}, UserState) -> {valid, UserState}; (_,{extension, _}, UserState) -> {unknown, UserState}; (_, valid, UserState) -> {valid, UserState}; (_, valid_peer, UserState) -> {valid, UserState} end, []} .fi .LP The possible path validation errors are given on form \fI{bad_cert, Reason}\fR\& where \fIReason\fR\& is: .RS 2 .TP 2 .B \fIunknown_ca\fR\&: 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 \fIpartial_chain\fR\&\&. .TP 2 .B \fIselfsigned_peer\fR\&: The chain consisted only of one self-signed certificate\&. .TP 2 .B \fIPKIX X-509-path validation error\fR\&: For possible reasons, see public_key:pkix_path_validation/3 .RE .RE .nf \fBcrl_check()\fR\& = boolean() | peer | best_effort .br .fi .RS .LP 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) of the certificate chain\&. Defaults to \fIfalse\fR\&\&. .RS 2 .TP 2 .B \fIpeer\fR\&: check is only performed on the peer certificate\&. .TP 2 .B \fIbest_effort\fR\&: if certificate revocation status cannot be determined it will be accepted as valid\&. .RE .LP The CA certificates specified for the connection will be used to construct the certificate chain validating the CRLs\&. .LP The CRLs will be fetched from a local or external cache\&. See ssl_crl_cache_api(3erl)\&. .RE .nf \fBcrl_cache_opts()\fR\& = .br {Module :: atom(), .br {DbHandle :: internal | term(), Args :: list()}} .br .fi .RS .LP Specify how to perform lookup and caching of certificate revocation lists\&. \fIModule\fR\& defaults to ssl_crl_cache with \fI DbHandle \fR\& being \fIinternal\fR\& and an empty argument list\&. .LP There are two implementations available: .RS 2 .TP 2 .B \fIssl_crl_cache\fR\&: 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: .RS 2 .TP 2 .B \fI{http, timeout()}\fR\&: Enables fetching of CRLs specified as http URIs inX509 certificate extensions\&. Requires the OTP inets application\&. .RE .TP 2 .B \fIssl_crl_hash_dir\fR\&: This module makes use of a directory where CRLs are stored in files named by the hash of the issuer name\&. .RS 2 .LP The file names consist of eight hexadecimal digits followed by \fI\&.rN\fR\&, where \fIN\fR\& is an integer, e\&.g\&. \fI1a2b3c4d\&.r0\fR\&\&. For the first version of the CRL, \fIN\fR\& starts at zero, and for each new version, \fIN\fR\& is incremented by one\&. The OpenSSL utility \fIc_rehash\fR\& creates symlinks according to this pattern\&. .RE .RS 2 .LP For a given hash value, this module finds all consecutive \fI\&.r*\fR\& files starting from zero, and those files taken together make up the revocation list\&. CRL files whose \fInextUpdate\fR\& fields are in the past, or that are issued by a different CA that happens to have the same name hash, are excluded\&. .RE .RS 2 .LP The following argument is required: .RE .RS 2 .TP 2 .B \fI{dir, string()}\fR\&: Specifies the directory in which the CRLs can be found\&. .RE .RE .RE .nf \fBroot_fun()\fR\& = function() .br .fi .RS .LP .nf fun(Chain::[public_key:der_encoded()]) -> {trusted_ca, DerCert::public_key:der_encoded()} | unknown_ca} .fi .LP 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\&. .RE .nf \fBprotocol_versions()\fR\& = [protocol_version()] .br .fi .RS .LP TLS protocol versions supported by started clients and servers\&. This option overrides the application environment option \fIprotocol_version\fR\& and \fIdtls_protocol_version\fR\&\&. If the environment option is not set, it defaults to all versions, supported by the SSL application\&. See also ssl(7)\&. .RE .nf \fBcustom_user_lookup()\fR\& = .br {Lookupfun :: function(), UserState :: any()} .br .fi .RS .LP The lookup fun is to defined as follows: .LP .nf fun(psk, PSKIdentity :: binary(), UserState :: term()) -> {ok, SharedSecret :: binary()} | error; fun(srp, Username :: binary(), UserState :: term()) -> {ok, {SRPParams :: srp_param_type(), Salt :: binary(), DerivedKey :: binary()}} | error. .fi .LP For Pre-Shared Key (PSK) cipher suites, the lookup fun is called by the client and server to determine the shared secret\&. When called by the client, \fIPSKIdentity\fR\& is set to the hint presented by the server or to undefined\&. When called by the server, \fIPSKIdentity\fR\& is the identity presented by the client\&. .LP For Secure Remote Password (SRP), the fun is only used by the server to obtain parameters that it uses to generate its session keys\&. \fIDerivedKey\fR\& is to be derived according to RFC 2945 and RFC 5054: \fIcrypto:sha([Salt, crypto:sha([Username, <<$:>>, Password])])\fR\& .RE .nf \fBsession_id()\fR\& = binary() .br .fi .RS .LP Identifies a TLS session\&. .RE .nf \fBlog_alert()\fR\& = boolean() .br .fi .RS .LP If set to \fIfalse\fR\&, TLS/DTLS Alert reports are not displayed\&. Deprecated in OTP 22, use {log_level, logging_level()} instead\&. .RE .nf \fBlogging_level()\fR\& = logger:level() | none | all .br .fi .RS .LP Specifies the log level for a TLS/DTLS connection\&. Alerts are logged on \fInotice\fR\& level, which is the default level\&. The level \fIdebug\fR\& triggers verbose logging of TLS/DTLS protocol messages\&. See also ssl(7) .RE .nf \fBhibernate_after()\fR\& = timeout() .br .fi .RS .LP When an integer-value is specified, \fITLS/DTLS-connection\fR\& goes into hibernation after the specified number of milliseconds of inactivity, thus reducing its memory footprint\&. When \fIundefined\fR\& is specified (this is the default), the process never goes into hibernation\&. .RE .nf \fBhandshake_size()\fR\& = integer() .br .fi .RS .LP Integer (24 bits unsigned)\&. Used to limit the size of valid TLS handshake packets to avoid DoS attacks\&. Defaults to 256*1024\&. .RE .nf \fBpadding_check()\fR\& = boolean() .br .fi .RS .LP Affects TLS-1\&.0 connections only\&. If set to \fIfalse\fR\&, it disables the block cipher padding check to be able to interoperate with legacy software\&. .LP .RS -4 .B Warning: .RE Using \fI{padding_check, boolean()}\fR\& makes TLS vulnerable to the Poodle attack\&. .RE .nf \fBbeast_mitigation()\fR\& = one_n_minus_one | zero_n | disabled .br .fi .RS .LP Affects TLS-1\&.0 connections only\&. Used to change the BEAST mitigation strategy to interoperate with legacy software\&. Defaults to \fIone_n_minus_one\fR\&\&. .LP \fIone_n_minus_one\fR\& - Perform 1/n-1 BEAST mitigation\&. .LP \fIzero_n\fR\& - Perform 0/n BEAST mitigation\&. .LP \fIdisabled\fR\& - Disable BEAST mitigation\&. .LP .RS -4 .B Warning: .RE Using \fI{beast_mitigation, disabled}\fR\& makes TLS-1\&.0 vulnerable to the BEAST attack\&. .RE .nf \fBssl_imp()\fR\& = new | old .br .fi .RS .LP Deprecated since OTP-17, has no effect\&. .RE .nf \fBsession_tickets()\fR\& = .br client_session_tickets() | server_session_tickets() .br .fi .RS .LP Configures the session ticket functionality in TLS 1\&.3 client and server\&. .RE .nf \fBkey_update_at()\fR\& = integer() >= 1 .br .fi .RS .LP Configures the maximum amount of bytes that can be sent on a TLS 1\&.3 connection before an automatic key update is performed\&. .LP There are cryptographic limits on the amount of plaintext which can be safely encrypted under a given set of keys\&. The current default ensures that data integrity will not be breached with probability greater than 1/2^57\&. For more information see Limits on Authenticated Encryption Use in TLS\&. .LP .RS -4 .B Warning: .RE The default value of this option shall provide the above mentioned security guarantees and it shall be reasonable for most applications (~353 TB)\&. .RE .nf \fBmiddlebox_comp_mode()\fR\& = boolean() .br .fi .RS .LP Configures the middlebox compatibility mode on a TLS 1\&.3 connection\&. .LP A significant number of middleboxes misbehave when a TLS 1\&.3 connection is negotiated\&. Implementations can increase the chance of making connections through those middleboxes by making the TLS 1\&.3 handshake more like a TLS 1\&.2 handshake\&. .LP The middlebox compatibility mode is enabled (\fItrue\fR\&) by default\&. .RE .nf \fBspawn_opts()\fR\& = [erlang:spawn_opt_option()] .br .fi .RS .LP Configures spawn options of TLS sender and receiver processes\&. .LP Setting up garbage collection options can be helpful for trade-offs between CPU usage and Memory usage\&. See \fIerlang:spawn_opt/2\fR\&\&. .LP For dist connections, default sender option is \fI[\&.\&.\&.{priority, max}]\fR\&, this priority option cannot be changed\&. For all connections, \fI\&.\&.\&.link\fR\& is added to receiver and cannot be changed\&. .RE .nf \fBkeep_secrets()\fR\& = boolean() .br .fi .RS .LP Configures a TLS 1\&.3 connection for keylogging .LP In order to retrieve keylog information on a TLS 1\&.3 connection, it must be configured in advance to keep the client_random and various handshake secrets\&. .LP The keep_secrets functionality is disabled (\fIfalse\fR\&) by default\&. .LP Added in OTP 23\&.2 .RE .SS TLS/DTLS OPTION DESCRIPTIONS - CLIENT .nf \fBclient_option()\fR\& = .br {verify, client_verify_type()} | .br {reuse_session, client_reuse_session()} | .br {reuse_sessions, client_reuse_sessions()} | .br {cacerts, client_cacerts()} | .br {cacertfile, client_cafile()} | .br {alpn_advertised_protocols, client_alpn()} | .br {client_preferred_next_protocols, .br client_preferred_next_protocols()} | .br {psk_identity, client_psk_identity()} | .br {srp_identity, client_srp_identity()} | .br {server_name_indication, sni()} | .br {max_fragment_length, max_fragment_length()} | .br {customize_hostname_check, customize_hostname_check()} | .br {fallback, fallback()} | .br {middlebox_comp_mode, middlebox_comp_mode()} | .br {certificate_authorities, client_certificate_authorities()} | .br {session_tickets, client_session_tickets()} | .br {use_ticket, use_ticket()} | .br {early_data, client_early_data()} .br .fi .nf \fBclient_verify_type()\fR\& = verify_type() .br .fi .RS .LP Defaults to \fIverify_none\fR\& as additional options are needed to be able to perform the certificate verification\&. A warning will be emitted unless \fIverify_none\fR\& is explicitly configured\&. Usually the applications will want to configure \fIverify_peer\fR\& together with an appropriate \fIcacert\fR\& or \fIcacertfile\fR\& option\&. For example an \fIHTTPS\fR\& client would normally use the option \fI{cacerts, public_key:cacerts_get()}\fR\& (available since OTP-25) to access the CA certificates provided by the OS\&. Using verify_none means that all x509-certificate path validation errors will be ignored\&. See also option verify_fun\&. .RE .nf \fBclient_reuse_session()\fR\& = .br session_id() | {session_id(), SessionData :: binary()} .br .fi .RS .LP Reuses a specific session\&. The session should be referred by its session id if it is earlier saved with the option \fI{reuse_sessions, save}\fR\& since OTP-21\&.3 or explicitly specified by its session id and associated data since OTP-22\&.3\&. See also SSL\&'s Users Guide, Session Reuse pre TLS 1\&.3\&. .RE .nf \fBclient_reuse_sessions()\fR\& = boolean() | save .br .fi .RS .LP When \fIsave\fR\& 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 The boolean value true specifies that if possible, automated 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\&. Since OTP-21\&.3\&. .RE .nf \fBclient_certificate_authorities()\fR\& = boolean() .br .fi .RS .LP If set to true, sends the certificate authorities extension in TLS-1\&.3 client hello\&. The default is false\&. Note that setting it to true may result in a big overhead if you have many trusted CA certificates\&. Since OTP-24\&.3\&. .RE .nf \fBclient_cacerts()\fR\& = .br [public_key:der_encoded()] | [public_key:combined_cert()] .br .fi .RS .LP The DER-encoded trusted certificates\&. If this option is supplied it overrides option \fIcacertfile\fR\&\&. .RE .nf \fBclient_cafile()\fR\& = file:filename() .br .fi .RS .LP Path to a file containing PEM-encoded CA certificates\&. The CA certificates are used during server authentication and when building the client certificate chain\&. .LP .RS -4 .B Note: .RE When PEM caching is enabled, files provided with this option will be checked for updates at fixed time intervals specified by the ssl_pem_cache_clean environment parameter\&. .LP .RS -4 .B Note: .RE Alternatively, CA certificates can be provided as a DER-encoded binary with client_cacerts option\&. .RE .nf \fBclient_alpn()\fR\& = [app_level_protocol()] .br .fi .RS .LP 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\&. .LP The list of protocols must not contain an empty binary\&. .LP The negotiated protocol can be retrieved using the \fInegotiated_protocol/1\fR\& function\&. .RE .nf \fBclient_preferred_next_protocols()\fR\& = .br {Precedence :: server | client, .br ClientPrefs :: [app_level_protocol()]} | .br {Precedence :: server | client, .br ClientPrefs :: [app_level_protocol()], .br Default :: app_level_protocol()} .br .fi .RS .LP Indicates that the client is to try to perform Next Protocol Negotiation\&. .LP 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\&. .LP 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\&. .LP 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\&. .RE .nf \fBmax_fragment_length()\fR\& = undefined | 512 | 1024 | 2048 | 4096 .br .fi .RS .LP Specifies the maximum fragment length the client is prepared to accept from the server\&. See RFC 6066 .RE .nf \fBclient_psk_identity()\fR\& = psk_identity() .br .fi .RS .LP Specifies the identity the client presents to the server\&. The matching secret is found by calling \fIuser_lookup_fun\fR\& .RE .nf \fBclient_srp_identity()\fR\& = srp_identity() .br .fi .RS .LP Specifies the username and password to use to authenticate to the server\&. .RE .nf \fBsni()\fR\& = hostname() | disable .br .fi .RS .LP Specify the hostname to be used in TLS Server Name Indication extension\&. If not specified it will default to the \fIHost\fR\& argument of connect/[3,4] unless it is of type inet:ipaddress()\&. .LP The \fIHostName\fR\& will also be used in the hostname verification of the peer certificate using public_key:pkix_verify_hostname/2\&. .LP The special value \fIdisable\fR\& prevents the Server Name Indication extension from being sent and disables the hostname verification check public_key:pkix_verify_hostname/2 .RE .nf \fBcustomize_hostname_check()\fR\& = list() .br .fi .RS .LP 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 .RE .nf \fBfallback()\fR\& = boolean() .br .fi .RS .LP Send special cipher suite TLS_FALLBACK_SCSV to avoid undesired TLS version downgrade\&. Defaults to false .LP .RS -4 .B Warning: .RE 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 .LP \fI ssl:connect(Host, Port, [\&.\&.\&.{versions, [\&'tlsv2\&', \&'tlsv1\&.1\&', \&'tlsv1\&']}])\fR\& .LP \fI ssl:connect(Host, Port, [\&.\&.\&.{versions, [tlsv1\&.1\&', \&'tlsv1\&']}, {fallback, true}])\fR\& .LP \fI ssl:connect(Host, Port, [\&.\&.\&.{versions, [\&'tlsv1\&']}, {fallback, true}]) \fR\& .LP 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\&. .RE .nf \fBclient_session_tickets()\fR\& = disabled | manual | auto .br .fi .RS .LP Configures the session ticket functionality\&. Allowed values are \fIdisabled\fR\&, \fImanual\fR\& and \fIauto\fR\&\&. If it is set to \fImanual\fR\& the client will send the ticket information to user process in a 3-tuple: .LP \fI{ssl, session_ticket, {SNI, TicketData}}\fR\& .LP where \fISNI\fR\& is the ServerNameIndication and \fITicketData\fR\& is the extended ticket data that can be used in subsequent session resumptions\&. .LP If it is set to \fIauto\fR\&, the client automatically handles received tickets and tries to use them when making new TLS connections (session resumption with pre-shared keys)\&. .LP .RS -4 .B Note: .RE This option is supported by TLS 1\&.3 and above\&. See also SSL\&'s Users Guide, Session Tickets and Session Resumption in TLS 1\&.3 .RE .nf \fBuse_ticket()\fR\& = [binary()] .br .fi .RS .LP Configures the session tickets to be used for session resumption\&. It is a mandatory option in \fImanual\fR\& mode (\fIsession_tickets = manual\fR\&)\&. .LP .RS -4 .B Note: .RE Session tickets are only sent to user if option \fIsession_tickets\fR\& is set to \fImanual\fR\& .LP This option is supported by TLS 1\&.3 and above\&. See also SSL\&'s Users Guide, Session Tickets and Session Resumption in TLS 1\&.3 .RE .nf \fBclient_early_data()\fR\& = binary() .br .fi .RS .LP Configures the early data to be sent by the client\&. .LP In order to be able to verify that the server has the intention to process the early data, the following 3-tuple is sent to the user process: .LP \fI{ssl, SslSocket, {early_data, Result}}\fR\& .LP where \fIResult\fR\& is either \fIaccepted\fR\& or \fIrejected\fR\&\&. .LP .RS -4 .B Warning: .RE It is the responsibility of the user to handle a rejected Early Data and to resend when it is appropriate\&. .RE .SS TLS/DTLS OPTION DESCRIPTIONS - SERVER .nf \fBserver_option()\fR\& = .br {cacerts, server_cacerts()} | .br {cacertfile, server_cafile()} | .br {dh, dh_der()} | .br {dhfile, dh_file()} | .br {verify, server_verify_type()} | .br {fail_if_no_peer_cert, fail_if_no_peer_cert()} | .br {certificate_authorities, server_certificate_authorities()} | .br {reuse_sessions, server_reuse_sessions()} | .br {reuse_session, server_reuse_session()} | .br {alpn_preferred_protocols, server_alpn()} | .br {next_protocols_advertised, server_next_protocol()} | .br {psk_identity, server_psk_identity()} | .br {sni_hosts, sni_hosts()} | .br {sni_fun, sni_fun()} | .br {honor_cipher_order, honor_cipher_order()} | .br {honor_ecc_order, honor_ecc_order()} | .br {client_renegotiation, client_renegotiation()} | .br {session_tickets, server_session_tickets()} | .br {anti_replay, anti_replay()} | .br {cookie, cookie()} | .br {early_data, server_early_data()} .br .fi .nf \fBserver_cacerts()\fR\& = .br [public_key:der_encoded()] | [public_key:combined_cert()] .br .fi .RS .LP The DER-encoded trusted certificates\&. If this option is supplied it overrides option \fIcacertfile\fR\&\&. .RE .nf \fBserver_certificate_authorities()\fR\& = boolean() .br .fi .RS .LP Determines if a TLS-1\&.3 server should include the authorities extension in its certificate request message that will be sent if the option \fIverify\fR\& is set to \fIverify_peer\fR\&\&. Defaults to \fItrue\fR\&\&. .LP A reason to exclude the extension would be if the server wants to communicate with clients incapable of sending complete certificate chains that adhere to the extension, but the server still has the capability to recreate a chain that it can verify\&. .RE .nf \fBserver_cafile()\fR\& = file:filename() .br .fi .RS .LP 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\&. .LP .RS -4 .B Note: .RE When PEM caching is enabled, files provided with this option will be checked for updates at fixed time intervals specified by the ssl_pem_cache_clean environment parameter\&. .LP .RS -4 .B Note: .RE Alternatively, CA certificates can be provided as a DER-encoded binary with server_cacerts option\&. .RE .nf \fBdh_der()\fR\& = binary() .br .fi .RS .LP The DER-encoded Diffie-Hellman parameters\&. If specified, it overrides option \fIdhfile\fR\&\&. .LP .RS -4 .B Warning: .RE The \fIdh_der\fR\& option is not supported by TLS 1\&.3\&. Use the \fIsupported_groups\fR\& option instead\&. .RE .nf \fBdh_file()\fR\& = file:filename() .br .fi .RS .LP 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\&. .LP .RS -4 .B Warning: .RE The \fIdh_file\fR\& option is not supported by TLS 1\&.3\&. Use the \fIsupported_groups\fR\& option instead\&. .RE .nf \fBserver_verify_type()\fR\& = verify_type() .br .fi .RS .LP Client certificates are an optional part of the TLS protocol\&. A server only does x509-certificate path validation in mode \fIverify_peer\fR\&\&. By default the server is in \fIverify_none\fR\& mode an hence will not send an certificate request to the client\&. When using \fIverify_peer\fR\& you may also want to specify the options fail_if_no_peer_cert and certificate_authorities\&. .RE .nf \fBfail_if_no_peer_cert()\fR\& = boolean() .br .fi .RS .LP Used together with \fI{verify, verify_peer}\fR\& by an TLS/DTLS server\&. If set to \fItrue\fR\&, the server fails if the client does not have a certificate to send, that is, sends an empty certificate\&. If set to \fIfalse\fR\&, it fails only if the client sends an invalid certificate (an empty certificate is considered valid)\&. Defaults to false\&. .RE .nf \fBserver_reuse_sessions()\fR\& = boolean() .br .fi .RS .LP 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\&. .RE .nf \fBserver_reuse_session()\fR\& = function() .br .fi .RS .LP Enables the TLS/DTLS server to have a local policy for deciding if a session is to be reused or not\&. Meaningful only if \fIreuse_sessions\fR\& is set to \fItrue\fR\&\&. \fISuggestedSessionId\fR\& is a \fIbinary()\fR\&, \fIPeerCert\fR\& is a DER-encoded certificate, \fICompression\fR\& is an enumeration integer, and \fICipherSuite\fR\& is of type \fIciphersuite()\fR\&\&. .RE .nf \fBserver_alpn()\fR\& = [app_level_protocol()] .br .fi .RS .LP Indicates the server will try to perform Application-Layer Protocol Negotiation (ALPN)\&. .LP 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\&. .LP The negotiated protocol can be retrieved using the \fInegotiated_protocol/1\fR\& function\&. .RE .nf \fBserver_next_protocol()\fR\& = [app_level_protocol()] .br .fi .RS .LP 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 \fInegotiated_next_protocol/1\fR\& method\&. .RE .nf \fBserver_psk_identity()\fR\& = psk_identity() .br .fi .RS .LP Specifies the server identity hint, which the server presents to the client\&. .RE .nf \fBhonor_cipher_order()\fR\& = boolean() .br .fi .RS .LP If set to \fItrue\fR\&, use the server preference for cipher selection\&. If set to \fIfalse\fR\& (the default), use the client preference\&. .RE .nf \fBsni_hosts()\fR\& = .br [{hostname(), [server_option() | common_option()]}] .br .fi .RS .LP If the server receives a SNI (Server Name Indication) from the client matching a host listed in the \fIsni_hosts\fR\& option, the specific options for that host will override previously specified options\&. The option \fIsni_fun\fR\&, and \fIsni_hosts\fR\& are mutually exclusive\&. .RE .nf \fBsni_fun()\fR\& = function() .br .fi .RS .LP 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 \fIfun module:function/1\fR\& The option \fIsni_fun\fR\&, and \fIsni_hosts\fR\& are mutually exclusive\&. .RE .nf \fBclient_renegotiation()\fR\& = boolean() .br .fi .RS .LP 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 \fIfalse\fR\&\&. The default value is \fItrue\fR\&\&. 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\&. .RE .nf \fBhonor_cipher_order()\fR\& = boolean() .br .fi .RS .LP If true, use the server\&'s preference for cipher selection\&. If false (the default), use the client\&'s preference\&. .RE .nf \fBhonor_ecc_order()\fR\& = boolean() .br .fi .RS .LP If true, use the server\&'s preference for ECC curve selection\&. If false (the default), use the client\&'s preference\&. .RE .nf \fBserver_session_tickets()\fR\& = disabled | stateful | stateless .br .fi .RS .LP Configures the session ticket functionality\&. Allowed values are \fIdisabled\fR\&, \fIstateful\fR\& and \fIstateless\fR\&\&. .LP If it is set to \fIstateful\fR\& or \fIstateless\fR\&, session resumption with pre-shared keys is enabled and the server will send stateful or stateless session tickets to the client after successful connections\&. .LP A stateful session ticket is a database reference to internal state information\&. A stateless session ticket is a self-encrypted binary that contains both cryptographic keying material and state data\&. .LP .RS -4 .B Note: .RE This option is supported by TLS 1\&.3 and above\&. See also SSL\&'s Users Guide, Session Tickets and Session Resumption in TLS 1\&.3 .RE .nf \fBanti_replay()\fR\& = .br \&'10k\&' | \&'100k\&' | .br {bloom_filter_window_size(), .br bloom_filter_hash_functions(), .br bloom_filter_bits()} .br .fi .RS .LP Configures the server\&'s built-in anti replay feature based on Bloom filters\&. .LP Allowed values are the pre-defined \fI\&'10k\&'\fR\&, \fI\&'100k\&'\fR\& or a custom 3-tuple that defines the properties of the bloom filters: \fI{WindowSize, HashFunctions, Bits}\fR\&\&. \fIWindowSize\fR\& is the number of seconds after the current Bloom filter is rotated and also the window size used for freshness checks\&. \fIHashFunctions\fR\& is the number hash functions and \fIBits\fR\& is the number of bits in the bit vector\&. \fI\&'10k\&'\fR\& and \fI\&'100k\&'\fR\& are simple defaults with the following properties: .RS 2 .TP 2 * \fI\&'10k\&'\fR\&: Bloom filters can hold 10000 elements with 3% probability of false positives\&. \fIWindowSize\fR\&: 10, \fIHashFunctions\fR\&: 5, \fIBits:\fR\& 72985 (8\&.91 KiB)\&. .LP .TP 2 * \fI\&'100k\&'\fR\&: Bloom filters can hold 100000 elements with 3% probability of false positives\&. \fIWindowSize\fR\&: 10, \fIHashFunctions\fR\&: 5, \fIBits\fR\&: 729845 (89\&.09 KiB)\&. .LP .RE .LP .RS -4 .B Note: .RE This option is supported by TLS 1\&.3 and above and only with stateless session tickets\&. Ticket lifetime, the number of tickets sent by the server and the maximum number of tickets stored by the server in stateful mode are configured by application variables\&. See also SSL\&'s Users Guide, Anti-Replay Protection in TLS 1\&.3 .RE .nf \fBcookie()\fR\& = boolean() .br .fi .RS .LP If \fItrue\fR\& (default), the server sends a cookie extension in its HelloRetryRequest messages\&. .LP .RS -4 .B Note: .RE The cookie extension has two main purposes\&. It allows the server to force the client to demonstrate reachability at their apparent network address (thus providing a measure of DoS protection)\&. This is primarily useful for non-connection-oriented transports\&. It also allows to offload the server\&'s state to the client\&. The cookie extension is enabled by default as it is a mandatory extension in RFC8446\&. .RE .nf \fBserver_early_data()\fR\& = disabled | enabled .br .fi .RS .LP Configures if the server accepts (\fIenabled\fR\&) or rejects (\fIrejects\fR\&) early data sent by a client\&. The default value is \fIdisabled\fR\&\&. .LP .RS -4 .B Warning: .RE This option is a placeholder, early data is not yet implemented on the server side\&. .RE .nf \fBconnection_info()\fR\& = .br [common_info() | .br curve_info() | .br ssl_options_info() | .br security_info()] .br .fi .nf \fBcommon_info()\fR\& = .br {protocol, protocol_version()} | .br {session_id, session_id()} | .br {session_resumption, boolean()} | .br {selected_cipher_suite, erl_cipher_suite()} | .br {sni_hostname, term()} | .br {srp_username, term()} .br .fi .nf \fBcurve_info()\fR\& = {ecc, {named_curve, term()}} .br .fi .nf \fBssl_options_info()\fR\& = tls_option() .br .fi .nf \fBsecurity_info()\fR\& = .br {client_random, binary()} | .br {server_random, binary()} | .br {master_secret, binary()} .br .fi .nf \fBconnection_info_items()\fR\& = [connection_info_item()] .br .fi .nf \fBconnection_info_item()\fR\& = .br protocol | session_id | session_resumption | .br selected_cipher_suite | sni_hostname | srp_username | ecc | .br client_random | server_random | master_secret | keylog | .br tls_options_name() .br .fi .nf \fBtls_options_name()\fR\& = atom() .br .fi .SH EXPORTS .LP .nf .B append_cipher_suites(Deferred, Suites) -> ciphers() .br .fi .br .RS .LP Types: .RS 3 Deferred = ciphers() | cipher_filters() .br Suites = ciphers() .br .RE .RE .RS .LP Make \fIDeferred\fR\& suites become the least preferred suites, that is put them at the end of the cipher suite list \fISuites\fR\& after removing them from \fISuites\fR\& if present\&. \fIDeferred\fR\& may be a list of cipher suites or a list of filters in which case the filters are use on \fISuites\fR\& to extract the Deferred cipher list\&. .RE .LP .nf .B cipher_suites(Description, Version) -> ciphers() .br .fi .br .RS .LP Types: .RS 3 Description = .br default | all | exclusive | anonymous | exclusive_anonymous .br Version = protocol_version() .br .RE .RE .RS .LP Lists all possible cipher suites corresponding to \fIDescription\fR\& that are available\&. The \fIexclusive\fR\& and \fIexclusive_anonymous\fR\& option will exclusively list cipher suites first supported in \fIVersion\fR\& whereas the other options are inclusive from the lowest possible version to \fIVersion\fR\&\&. The \fIall\fR\& options includes all suites except the anonymous and no anonymous suites are supported by default\&. .LP .RS -4 .B Note: .RE TLS-1\&.3 has no overlapping cipher suites with previous TLS versions, that is the result of \fIcipher_suites(all, \&'tlsv1\&.3\&')\&.\fR\& contains a separate set of suites that can be used with TLS-1\&.3 an other set that can be used if a lower version is negotiated\&. PRE TLS-1\&.3 so called \fIPSK\fR\& and \fISRP\fR\& suites need extra configuration to work see user lookup function\&. No anonymous suites are supported by TLS-1\&.3\&. .LP Also note that the cipher suites returned by this function are the cipher suites that the OTP ssl application can support provided that they are supported by the cryptolib linked with the OTP crypto application\&. Use ssl:filter_cipher_suites(Suites, [])\&. to filter the list for the current cryptolib\&. Note that cipher suites may be filtered out because they are too old or too new depending on the cryptolib .RE .LP .nf .B cipher_suites(Description, Version, StringType :: rfc | openssl) -> .B [string()] .br .fi .br .RS .LP Types: .RS 3 Description = default | all | exclusive | anonymous .br Version = protocol_version() .br .RE .RE .RS .LP Same as cipher_suites/2 but lists RFC or OpenSSL string names instead of erl_cipher_suite() .RE .LP .nf .B eccs() -> NamedCurves .br .fi .br .nf .B eccs(Version) -> NamedCurves .br .fi .br .RS .LP Types: .RS 3 Version = protocol_version() .br NamedCurves = [named_curve()] .br .RE .RE .RS .LP Returns a list of supported ECCs\&. \fIeccs()\fR\& is equivalent to calling \fIeccs(Protocol)\fR\& with all supported protocols and then deduplicating the output\&. .RE .LP .nf .B clear_pem_cache() -> ok .br .fi .br .RS .LP PEM files, used by ssl API-functions, are cached for performance reasons\&. The cache is automatically checked at regular intervals to see if any cache entries should be invalidated\&. .LP This function provides a way to unconditionally clear the entire cache, thereby forcing a reload of previously cached PEM files\&. .RE .LP .nf .B connect(TCPSocket, TLSOptions) -> .B {ok, sslsocket()} | .B {error, reason()} | .B {option_not_a_key_value_tuple, any()} .br .fi .br .nf .B connect(TCPSocket, TLSOptions, Timeout) -> .B {ok, sslsocket()} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 TCPSocket = socket() .br TLSOptions = [tls_client_option()] .br Timeout = timeout() .br .RE .RE .RS .LP Upgrades a \fIgen_tcp\fR\&, or equivalent, connected socket to a TLS socket, that is, performs the client-side TLS handshake\&. .LP .RS -4 .B Note: .RE If the option \fIverify\fR\& is set to \fIverify_peer\fR\& the option \fIserver_name_indication\fR\& 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 \fIReferenceID\fR\&, which is probably not what you want\&. .LP If the option \fI{handshake, hello}\fR\& is used the handshake is paused after receiving the server hello message and the success response is \fI{ok, SslSocket, Ext}\fR\& instead of \fI{ok, SslSocket}\fR\&\&. Thereafter the handshake is continued or canceled by calling \fIhandshake_continue/3\fR\& or \fIhandshake_cancel/1\fR\&\&. .LP If the option \fIactive\fR\& is set to \fIonce\fR\&, \fItrue\fR\& or an integer value, the process owning the sslsocket will receive messages of type active_msgs() .RE .LP .nf .B connect(Host, Port, TLSOptions) -> .B {ok, sslsocket()} | .B {ok, sslsocket(), Ext :: protocol_extensions()} | .B {error, reason()} | .B {option_not_a_key_value_tuple, any()} .br .fi .br .nf .B connect(Host, Port, TLSOptions, Timeout) -> .B {ok, sslsocket()} | .B {ok, sslsocket(), Ext :: protocol_extensions()} | .B {error, reason()} | .B {option_not_a_key_value_tuple, any()} .br .fi .br .RS .LP Types: .RS 3 Host = host() .br Port = inet:port_number() .br TLSOptions = [tls_client_option()] .br Timeout = timeout() .br .RE .RE .RS .LP Opens a TLS/DTLS connection to \fIHost\fR\&, \fIPort\fR\&\&. .LP When the option \fIverify\fR\& is set to \fIverify_peer\fR\& 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 checks by using the full possibilities of the public_key:pkix_verify_hostname/3 API\&. When the option \fIserver_name_indication\fR\& is provided, its value (the DNS name) will be used as \fIReferenceID\fR\& to public_key:pkix_verify_hostname/2\&. When no \fIserver_name_indication\fR\& option is given, the \fIHost\fR\& argument will be used as Server Name Indication extension\&. The \fIHost\fR\& argument will also be used for the public_key:pkix_verify_hostname/2 check and if the \fIHost\fR\& argument is an \fIinet:ip_address()\fR\& the \fIReferenceID\fR\& used for the check will be \fI{ip, Host}\fR\& otherwise \fIdns_id\fR\& will be assumed with a fallback to \fIip\fR\& if that fails\&. .LP .RS -4 .B Note: .RE According to good practices certificates should not use IP-addresses as "server names"\&. It would be very surprising if this happened outside a closed network\&. .LP If the option \fI{handshake, hello}\fR\& is used the handshake is paused after receiving the server hello message and the success response is \fI{ok, SslSocket, Ext}\fR\& instead of \fI{ok, SslSocket}\fR\&\&. Thereafter the handshake is continued or canceled by calling \fIhandshake_continue/3\fR\& or \fIhandshake_cancel/1\fR\&\&. .LP If the option \fIactive\fR\& is set to \fIonce\fR\&, \fItrue\fR\& or an integer value, the process owning the sslsocket will receive messages of type active_msgs() .RE .LP .nf .B close(SslSocket) -> ok | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Reason = any() .br .RE .RE .RS .LP Closes a TLS/DTLS connection\&. .RE .LP .nf .B close(SslSocket, How) -> .B ok | {ok, port()} | {ok, port(), Data} | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br How = timeout() | {NewController :: pid(), timeout()} .br Data = binary() .br Reason = any() .br .RE .RE .RS .LP Closes or downgrades a TLS connection\&. In the latter case the transport connection will be handed over to the \fINewController\fR\& process after receiving the TLS close alert from the peer\&. The returned transport socket will have the following options set: \fI[{active, false}, {packet, 0}, {mode, binary}]\fR\&\&. .LP In case of downgrade, the close function might return some binary data that should be treated by the user as the first bytes received on the downgraded connection\&. .RE .LP .nf .B controlling_process(SslSocket, NewOwner) -> ok | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br NewOwner = pid() .br Reason = any() .br .RE .RE .RS .LP Assigns a new controlling process to the SSL socket\&. A controlling process is the owner of an SSL socket, and receives all messages from the socket\&. .RE .LP .nf .B connection_information(SslSocket) -> .B {ok, Result} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Result = connection_info() .br .RE .RE .RS .LP Returns the most relevant information about the connection, ssl options that are undefined will be filtered out\&. Note that values that affect the security of the connection will only be returned if explicitly requested by connection_information/2\&. .LP .RS -4 .B Note: .RE The legacy \fIItem = cipher_suite\fR\& was removed in OTP-23\&. Previously it returned the cipher suite on its (undocumented) legacy format\&. It is replaced by \fIselected_cipher_suite\fR\&\&. .RE .LP .nf .B connection_information(SslSocket, Items) -> .B {ok, Result} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Items = connection_info_items() .br Result = connection_info() .br .RE .RE .RS .LP Returns the requested information items about the connection, if they are defined\&. .LP Note that client_random, server_random, master_secret and keylog are values that affect the security of connection\&. Meaningful atoms, not specified above, are the ssl option names\&. .LP In order to retrieve keylog and other secret information from a TLS 1\&.3 connection, keep_secrets must be configured in advance and set to \fItrue\fR\&\&. .LP .RS -4 .B Note: .RE If only undefined options are requested the resulting list can be empty\&. .RE .LP .nf .B filter_cipher_suites(Suites, Filters) -> Ciphers .br .fi .br .RS .LP Types: .RS 3 Suites = ciphers() .br Filters = cipher_filters() .br Ciphers = ciphers() .br .RE .RE .RS .LP Removes cipher suites if any of the filter functions returns false for any part of the cipher suite\&. If no filter function is supplied for some part the default behaviour regards it as if there was a filter function that returned true\&. For examples see Customizing cipher suites Additionally, this function also filters the cipher suites to exclude cipher suites not supported by the cryptolib used by the OTP crypto application\&. That is calling ssl:filter_cipher_suites(Suites, []) will be equivalent to only applying the filters for cryptolib support\&. .RE .LP .nf .B format_error(Reason :: Reason | {error, Reason}) -> string() .br .fi .br .RS .LP Types: .RS 3 Reason = any() .br .RE .RE .RS .LP Presents the error returned by an SSL function as a printable string\&. .RE .LP .nf .B getopts(SslSocket, OptionNames) -> .B {ok, [gen_tcp:option()]} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br OptionNames = [gen_tcp:option_name()] .br .RE .RE .RS .LP Gets the values of the specified socket options\&. .RE .LP .nf .B getstat(SslSocket) -> {ok, OptionValues} | {error, inet:posix()} .br .fi .br .nf .B getstat(SslSocket, Options) -> .B {ok, OptionValues} | {error, inet:posix()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Options = [inet:stat_option()] .br OptionValues = [{inet:stat_option(), integer()}] .br .RE .RE .RS .LP Gets one or more statistic options for the underlying TCP socket\&. .LP See inet:getstat/2 for statistic options description\&. .RE .LP .nf .B handshake(HsSocket) -> .B {ok, SslSocket} | .B {ok, SslSocket, Ext} | .B {error, Reason} .br .fi .br .nf .B handshake(HsSocket, Timeout) -> .B {ok, SslSocket} | .B {ok, SslSocket, Ext} | .B {error, Reason} .br .fi .br .RS .LP Types: .RS 3 HsSocket = sslsocket() .br Timeout = timeout() .br SslSocket = sslsocket() .br Ext = protocol_extensions() .br Reason = closed | timeout | error_alert() .br .RE .RE .RS .LP Performs the TLS/DTLS server-side handshake\&. .LP Returns a new TLS/DTLS socket if the handshake is successful\&. .LP If the option \fIactive\fR\& is set to \fIonce\fR\&, \fItrue\fR\& or an integer value, the process owning the sslsocket will receive messages of type active_msgs() .LP .RS -4 .B Warning: .RE Not setting the timeout makes the server more vulnerable to DoS attacks\&. .RE .LP .nf .B handshake(Socket, Options) -> .B {ok, SslSocket} | .B {ok, SslSocket, Ext} | .B {error, Reason} .br .fi .br .nf .B handshake(Socket, Options, Timeout) -> .B {ok, SslSocket} | .B {ok, SslSocket, Ext} | .B {error, Reason} .br .fi .br .RS .LP Types: .RS 3 Socket = socket() | sslsocket() .br SslSocket = sslsocket() .br Options = [server_option()] .br Timeout = timeout() .br Ext = protocol_extensions() .br Reason = closed | timeout | {options, any()} | error_alert() .br .RE .RE .RS .LP If \fISocket\fR\& is a ordinary \fIsocket()\fR\&: upgrades a \fIgen_tcp\fR\&, or equivalent, socket to an SSL socket, that is, performs the TLS server-side handshake and returns a TLS socket\&. .LP .RS -4 .B Warning: .RE The ordinary \fISocket\fR\& shall be in passive mode ({active, false}) before calling this function, and before the client tries to connect with TLS, or else the behavior of this function is undefined\&. The best way to ensure this is to create the ordinary listen socket in passive mode\&. .LP If \fISocket\fR\& is an sslsocket() : provides extra TLS/DTLS options to those specified in listen/2 and then performs the TLS/DTLS handshake\&. Returns a new TLS/DTLS socket if the handshake is successful\&. .LP .RS -4 .B Warning: .RE Not setting the timeout makes the server more vulnerable to DoS attacks\&. .LP If option \fI{handshake, hello}\fR\& is specified the handshake is paused after receiving the client hello message and the success response is \fI{ok, SslSocket, Ext}\fR\& instead of \fI{ok, SslSocket}\fR\&\&. Thereafter the handshake is continued or canceled by calling \fIhandshake_continue/3\fR\& or \fIhandshake_cancel/1\fR\&\&. .LP If the option \fIactive\fR\& is set to \fIonce\fR\&, \fItrue\fR\& or an integer value, the process owning the sslsocket will receive messages of type active_msgs() .RE .LP .nf .B handshake_cancel(Sslsocket :: #sslsocket{}) -> any() .br .fi .br .RS .LP Cancel the handshake with a fatal \fIUSER_CANCELED\fR\& alert\&. .RE .LP .nf .B handshake_continue(HsSocket, Options) -> .B {ok, SslSocket} | {error, Reason} .br .fi .br .nf .B handshake_continue(HsSocket, Options, Timeout) -> .B {ok, SslSocket} | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 HsSocket = sslsocket() .br Options = [tls_client_option() | tls_server_option()] .br Timeout = timeout() .br SslSocket = sslsocket() .br Reason = closed | timeout | error_alert() .br .RE .RE .RS .LP Continue the TLS handshake, possibly with new, additional or changed options\&. .RE .LP .nf .B listen(Port, Options) -> {ok, ListenSocket} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 Port = inet:port_number() .br Options = [tls_server_option()] .br ListenSocket = sslsocket() .br .RE .RE .RS .LP Creates an SSL listen socket\&. .RE .LP .nf .B negotiated_protocol(SslSocket) -> {ok, Protocol} | {error, Reason} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Protocol = binary() .br Reason = protocol_not_negotiated .br .RE .RE .RS .LP Returns the protocol negotiated through ALPN or NPN extensions\&. .RE .LP .nf .B peercert(SslSocket) -> {ok, Cert} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Cert = public_key:der_encoded() .br .RE .RE .RS .LP The peer certificate is returned as a DER-encoded binary\&. The certificate can be decoded with public_key:pkix_decode_cert/2 Suggested further reading about certificates is public_key User\&'s Guide and ssl User\&'s Guide .RE .LP .nf .B peername(SslSocket) -> {ok, {Address, Port}} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Address = inet:ip_address() .br Port = inet:port_number() .br .RE .RE .RS .LP Returns the address and port number of the peer\&. .RE .LP .nf .B prepend_cipher_suites(Preferred, Suites) -> ciphers() .br .fi .br .RS .LP Types: .RS 3 Preferred = ciphers() | cipher_filters() .br Suites = ciphers() .br .RE .RE .RS .LP Make \fIPreferred\fR\& suites become the most preferred suites that is put them at the head of the cipher suite list \fISuites\fR\& after removing them from \fISuites\fR\& if present\&. \fIPreferred\fR\& may be a list of cipher suites or a list of filters in which case the filters are use on \fISuites\fR\& to extract the preferred cipher list\&. .RE .LP .nf .B prf(SslSocket, Secret, Label, Seed, WantedLength) -> .B {ok, binary()} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Secret = binary() | master_secret .br Label = binary() .br Seed = [binary() | prf_random()] .br WantedLength = integer() >= 0 .br .RE .RE .RS .LP Uses the Pseudo-Random Function (PRF) of a TLS session to generate extra key material\&. It either takes user-generated values for \fISecret\fR\& and \fISeed\fR\& or atoms directing it to use a specific value from the session security parameters\&. .RE .LP .nf .B recv(SslSocket, Length) -> {ok, Data} | {error, reason()} .br .fi .br .nf .B recv(SslSocket, Length, Timeout) -> {ok, Data} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Length = integer() >= 0 .br Data = binary() | list() | HttpPacket .br Timeout = timeout() .br HttpPacket = any() .br .RS 2 See the description of \fIHttpPacket\fR\& in \fIerlang:decode_packet/3\fR\& in ERTS\&. .RE .RE .RE .RS .LP Receives a packet from a socket in passive mode\&. A closed socket is indicated by return value \fI{error, closed}\fR\&\&. .LP Argument \fILength\fR\& is meaningful only when the socket is in mode \fIraw\fR\& and denotes the number of bytes to read\&. If \fILength\fR\& = 0, all available bytes are returned\&. If \fILength\fR\& > 0, exactly \fILength\fR\& bytes are returned, or an error; possibly discarding less than \fILength\fR\& bytes of data when the socket gets closed from the other side\&. .LP Optional argument \fITimeout\fR\& specifies a time-out in milliseconds\&. The default value is \fIinfinity\fR\&\&. .RE .LP .nf .B renegotiate(SslSocket) -> ok | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br .RE .RE .RS .LP Initiates a new handshake\&. A notable return value is \fI{error, renegotiation_rejected}\fR\& indicating that the peer refused to go through with the renegotiation, but the connection is still active using the previously negotiated session\&. .RE .LP .nf .B update_keys(SslSocket, Type) -> ok | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Type = write | read_write .br .RE .RE .RS .LP There are cryptographic limits on the amount of plaintext which can be safely encrypted under a given set of keys\&. If the amount of data surpasses those limits, a key update is triggered and a new set of keys are installed\&. See also the option key_update_at\&. .LP This function can be used to explicitly start a key update on a TLS 1\&.3 connection\&. There are two types of the key update: if \fIType\fR\& is set to \fIwrite\fR\&, only the writing key is updated; if \fIType\fR\& is set to \fIread_write\fR\&, both the reading and writing keys are updated\&. .RE .LP .nf .B send(SslSocket, Data) -> ok | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Data = iodata() .br .RE .RE .RS .LP Writes \fIData\fR\& to \fISslSocket\fR\&\&. .LP A notable return value is \fI{error, closed}\fR\& indicating that the socket is closed\&. .RE .LP .nf .B setopts(SslSocket, Options) -> ok | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Options = [gen_tcp:option()] .br .RE .RE .RS .LP Sets options according to \fIOptions\fR\& for socket \fISslSocket\fR\&\&. .RE .LP .nf .B shutdown(SslSocket, How) -> ok | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br How = read | write | read_write .br .RE .RE .RS .LP Immediately closes a socket in one or two directions\&. .LP \fIHow == write\fR\& means closing the socket for writing, reading from it is still possible\&. .LP To be able to handle that the peer has done a shutdown on the write side, option \fI{exit_on_close, false}\fR\& is useful\&. .RE .LP .nf .B sockname(SslSocket) -> {ok, {Address, Port}} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 SslSocket = sslsocket() .br Address = inet:ip_address() .br Port = inet:port_number() .br .RE .RE .RS .LP Returns the local address and port number of socket \fISslSocket\fR\&\&. .RE .LP .nf .B start() -> ok | {error, reason()} .br .fi .br .nf .B start(Type :: permanent | transient | temporary) -> .B ok | {error, reason()} .br .fi .br .RS .LP Starts the SSL application\&. Default type is \fItemporary\fR\&\&. .RE .LP .nf .B stop() -> ok .br .fi .br .RS .LP Stops the SSL application\&. .RE .LP .nf .B str_to_suite(CipherSuiteName) -> .B erl_cipher_suite() | .B {error, {not_recognized, CipherSuiteName}} .br .fi .br .RS .LP Types: .RS 3 CipherSuiteName = string() .br .RE .RE .RS .LP Converts an RFC or OpenSSL name string to an erl_cipher_suite() Returns an error if the cipher suite is not supported or the name is not a valid cipher suite name\&. .RE .LP .nf .B suite_to_openssl_str(CipherSuite) -> string() .br .fi .br .RS .LP Types: .RS 3 CipherSuite = erl_cipher_suite() .br .RE .RE .RS .LP Converts erl_cipher_suite() to OpenSSL name string\&. .LP PRE TLS-1\&.3 these names differ for RFC names .RE .LP .nf .B suite_to_str(CipherSuite) -> string() .br .fi .br .RS .LP Types: .RS 3 CipherSuite = erl_cipher_suite() .br .RE .RE .RS .LP Converts erl_cipher_suite() to RFC name string\&. .RE .LP .nf .B transport_accept(ListenSocket) -> .B {ok, SslSocket} | {error, reason()} .br .fi .br .nf .B transport_accept(ListenSocket, Timeout) -> .B {ok, SslSocket} | {error, reason()} .br .fi .br .RS .LP Types: .RS 3 ListenSocket = sslsocket() .br Timeout = timeout() .br SslSocket = sslsocket() .br .RE .RE .RS .LP Accepts an incoming connection request on a listen socket\&. \fIListenSocket\fR\& must be a socket returned from listen/2\&. The socket returned is to be passed to handshake/[2,3] to complete handshaking, that is, establishing the TLS/DTLS connection\&. .LP .RS -4 .B Warning: .RE Most API functions require that the TLS/DTLS connection is established to work as expected\&. .LP The accepted socket inherits the options set for \fIListenSocket\fR\& in listen/2\&. .LP The default value for \fITimeout\fR\& is \fIinfinity\fR\&\&. If \fITimeout\fR\& is specified and no connection is accepted within the given time, \fI{error, timeout}\fR\& is returned\&. .RE .LP .nf .B versions() -> [VersionInfo] .br .fi .br .RS .LP Types: .RS 3 VersionInfo = .br {ssl_app, string()} | .br {supported | available | implemented, [tls_version()]} | .br {supported_dtls | available_dtls | implemented_dtls, .br [dtls_version()]} .br .RE .RE .RS .LP Lists information, mainly concerning TLS/DTLS versions, in runtime for debugging and testing purposes\&. .RS 2 .TP 2 .B \fIapp_vsn\fR\&: The application version of the SSL application\&. .TP 2 .B \fIsupported\fR\&: TLS versions supported with current application environment and crypto library configuration\&. Overridden by a version option on connect/[2,3,4], listen/2, and handshake/[2,3]\&. For the negotiated TLS version, see connection_information/1 \&. .TP 2 .B \fIsupported_dtls\fR\&: DTLS versions supported with current application environment and crypto library configuration\&. Overridden by a version option on connect/[2,3,4], listen/2, and handshake/[2,3]\&. For the negotiated DTLS version, see connection_information/1 \&. .TP 2 .B \fIavailable\fR\&: All TLS versions supported with the linked crypto library\&. .TP 2 .B \fIavailable_dtls\fR\&: All DTLS versions supported with the linked crypto library\&. .TP 2 .B \fIimplemented\fR\&: All TLS versions supported by the SSL application if linked with a crypto library with the necessary support\&. .TP 2 .B \fIimplemented_dtls\fR\&: All DTLS versions supported by the SSL application if linked with a crypto library with the necessary support\&. .RE .RE .SH "SEE ALSO" .LP inet(3erl) and gen_tcp(3erl) gen_udp(3erl)