From 58f7f2046ec48927c9f41d8e82510959c4c4ae3b Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Thu, 7 Jun 2018 14:52:59 +0200 Subject: public_key: Clearify pkix_verify_hostname documentation --- lib/public_key/doc/src/public_key.xml | 57 +++++++++++++++++++++++++---- lib/public_key/doc/src/using_public_key.xml | 4 +- 2 files changed, 52 insertions(+), 9 deletions(-) (limited to 'lib/public_key') diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 5d57109140..30ec70aa9b 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -969,35 +969,76 @@ fun(#'DistributionPoint'{}, #'CertificateList'{},

This function checks that the Presented Identifier (e.g hostname) in a peer certificate - is in agreement with the Reference Identifier that the client expects to be connected to. + is in agreement with at least one of the Reference Identifier that the client expects to be connected to. The function is intended to be added as an extra client check of the peer certificate when performing public_key:pkix_path_validation/3

See RFC 6125 for detailed information about hostname verification. - The User's Manual + The User's Guide and code examples describes this function more detailed.

The {OtherRefId,term()} is defined by the user and is passed to the match_fun, if defined. - If that term is a binary, it will be converted to a string. + If the term in OtherRefId is a binary, it will be converted to a string.

The ip Reference ID takes an inet:ip_address() or an ip address in string format (E.g "10.0.1.1" or "1234::5678:9012") as second element.

-

See pkix_verify_hostname_match_fun/1 for a - function that return a fun suitable for this option. -

+

The options are:

+ + match_fun + + The fun/2 in this option replaces the default host name matching rules. The fun should return a + boolean to tell if the Reference ID and Presented ID matches or not. The fun can also return a third + value. the atom default, if the default matching rules shall apply. + This makes it possible to augment the tests with a special case: + +fun(....) -> true; % My special case + (_, _) -> default % all others falls back to the inherit tests +end + +
See pkix_verify_hostname_match_fun/1 for a + function that takes a protocol name as argument and returns a fun/2 suitable for this option and + Re-defining the match operation + in the User's Guide for an example. +
+ + fail_callback + If a matching fails, there could be circumstances when the certificate should be accepted anyway. Think for + example of a web browser where you choose to accept an outdated certificate. This options enables implementation + of such a function. This fun/1 is called when no ReferenceID matches. The return value of the fun + (a boolean()) decides the outcome. If true the the certificate is accepted otherwise + it is rejected. See + "Pinning" a Certificate + in the User's Guide. + + + fqdn_fun + This option augments the host name extraction from URIs and other Reference IDs. It could for example be + a very special URI that is not standardised. The fun takes a Reference ID as argument and returns one of: + + the hostname + the atom default: the default host name extract function will be used + the atom undefined: a host name could not be extracted. The pkix_verify_hostname/3 + will return false. + +
For an example, see + Hostname extraction + in the User's Guide. +
+
+
- pkix_verify_hostname_match_fun(Alg) -> fun(RefId | FQDN::string(), PresentedID) -> boolean() | default + pkix_verify_hostname_match_fun(Protcol) -> fun(RefId | FQDN::string(), PresentedID) -> boolean() | default Returns a fun that is intendended as argument to the match_fun option in pkix_verify_hostname/3. - Alg = https + Protocol = https The algorithm for wich the fun should implement the special matching rules RefId See pkix_verify_hostname/3. diff --git a/lib/public_key/doc/src/using_public_key.xml b/lib/public_key/doc/src/using_public_key.xml index 417d479da3..b936b7fcb5 100644 --- a/lib/public_key/doc/src/using_public_key.xml +++ b/lib/public_key/doc/src/using_public_key.xml @@ -570,6 +570,7 @@ true = public_key:verify(Digest, none, Signature, PublicKey), fqdn_fun and match_fun.

+ Hostname extraction

The fqdn_fun extracts hostnames (Fully Qualified Domain Names) from uri_id or other ReferenceIDs that are not pre-defined in the public_key function. @@ -595,7 +596,8 @@ true = public_key:verify(Digest, none, Signature, PublicKey),

- Re-defining the match operations + + Re-defining the match operation

The default matching handles dns_id and uri_id. In an uri_id the value is tested for equality with a value from the Subject Alternate Name. If som other kind of matching is needed, use the match_fun option. -- cgit v1.2.3