<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="info" docName="draft-hallambaker-web-service-discovery-10" indexInclude="false" ipr="trust200902" scripts="Common,Latin" sortRefs="true" submissionType="independent" symRefs="true" tocDepth="3" tocInclude="true" version="3" xml:lang="en"><front>
<title abbrev="DNS Web Service Discovery">DNS Web Service Discovery</title>
<seriesInfo name="draft-hallambaker-web-service-discovery-10" value="draft-hallambaker-web-service-discovery" stream="independent"/>
<author fullname="Phillip Hallam-Baker" initials="P. M." surname="Hallam-Baker"><address>
<email>phill@hallambaker.com</email>
</address>
</author>
<date day="14" month="October" year="2024"/>
<area/>
<workgroup/>
<abstract>
<t>This document describes a standardized approach to discovering Web Service Endpoints from a DNS name. Services are advertised using the DNS SRV and TXT records and the HTTP Well Known Service conventions. </t>
<t>This document is also available online at <eref target="http://mathmesh.com/Documents/draft-hallambaker-web-service-discovery.html"></eref>.</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="n-introduction"><t>Web services are traditionally identified by means of a URI specifying a Web Service Endpoint (WSE). This is approach is unsatisfactory in many situations:</t>
<ul>
<li>Specification of the Web Service requires the transport and presentation protocols to be fixed. </li>
<li>The discovery mechanism does not provide support for load balancing or fault tolerance.</li>
<li>The identifiers are unsuited for human interaction.</li>
</ul>
<t>The last consideration is a particular concern where an account identifier is exposed to the user. Attempts to 'teach' users to use URIs as account identifiers have been predictably unsuccessful. Users expect and require accounts to be of the form user@example.com and not http://service.example.com/service/user.</t>
<t>The Web Service discovery process described in this specification builds on the approach specified in DNS-Based Service Discovery <xref target="RFC6763"></xref>. This uses DNS SRV records as the basis for service discovery and TXT records as the basis for service description. This approach allows Web Services to make use of the load balancing and fault tolerance features of SRV and the service negotiation capabilities provided by the service description.</t>
<t>One difficulty that is frequently encountered in attempting to make use of DNS records for service discovery is that it is not always possible for an application process to access this information. Specifications address the world as it actually is rather than as some believe it should be have proven more robust in real world deployment than those that do not. The discovery process defined includes a fallback strategy to enable clients to achieve Web Service discovery in these circumstances.</t>
<t>Another difficulty that is encountered is that the SRV record maps service names to host names rather than Web Service Endpoints. A convention is thus required to map a host name and protocol prefix to a Web Service Endpoint. The HTTP Well Known Service <xref target="RFC5785"></xref> mechanism is used for this purpose.</t>
<t>While the approach adopted in this specification closely follows that of <xref target="RFC6763"></xref>, there is an important difference in that the earlier specification sets out a framework which Web Services may apply to develop a discovery approach that suits their particular needs while this specification defines exactly one such approach. In particular, the use of a common set of TXT keys to specify service parameters enables service discovery and negotiation to be delegated to common support libraries rather than being implemented independently in each application.</t>
</section>
<section title="Definitions" anchor="n-definitions"><t>This section presents the related specifications and standard, the terms that are used as terms of art within the documents and the terms used as requirements language.</t>
<section title="Requirements Language" anchor="n-requirements-language"><t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in [RFC2119].</t>
</section>
<section title="Defined Terms" anchor="n-defined-terms"><dl>
<dt>Web Service</dt>
<dd>
<t>An Internet service provided by one or more Web Service Hosts that are addressable by a single Web Service Endpoint and are intended to provide logically equivalent services.</t>
</dd>
<dt>Web Service Endpoint (WSE)</dt>
<dd>
<t>A URI that specifies a Web Service or Web Service Host.</t>
</dd>
<dt>Web Service Host</dt>
<dd>
<t>The actual machine (physical or virtual) that provides a Web Service</t>
</dd>
</dl>
</section>
</section>
<section title="Service Discovery" anchor="n-service-discovery"><t>Service discovery is the process of resolving the address of a Web Service to a Web Service Endpoint, a URI <xref target="RFC3986"></xref> at which the service is provided.</t>
<section title="Host Identification" anchor="n-host-identification"><t>The first step in service discovery is to resolve the &lt;domain&gt; and &lt;service&gt; identifiers to the IP address of a host that provides that service.</t>
<section title="SRV Host discovery" anchor="n-srv-host-discovery"><t>A client attempting to connect to the service first attempts to locate an SRV record <xref target="RFC2782"></xref> for the specified service:</t>
<sourcecode>_&lt;service&gt;._tcp.&lt;domain&gt;  SRV  &lt;priority&gt; &lt;weight&gt; &lt;port&gt; &lt;host&gt;</sourcecode>
<t>Where &lt;service&gt; is the IANA assigned service name, &lt;priority&gt; and &lt;weight&gt; are the SRV priority and weight parameters specified in <xref target="RFC2782"></xref>, &lt;port&gt; is the TCP port number and &lt;host&gt; is the DNS name of the host for which the service advertisement is made. </t>
<t>If no SRV records are found, the client <bcp14>MAY</bcp14> abort the connection or attempt use of the Fallback Discovery process described below.</t>
</section>
</section>
<section title="Service Description" anchor="n-service-description"><t>The second step in service discovery is to identify the attributes of the Web Service and Web Service Hosts providing that service.</t>
<section title="TXT Service and Host Description" anchor="n-txt-service-and-host-description"><t>A service <bcp14>MAY</bcp14> advertise service and/or host description information using TXT records as described in DNS-Based Service Discovery <xref target="RFC6763"></xref> . These have the following format:</t>
<sourcecode>_&lt;service&gt;._tcp.&lt;domain&gt;  TXT "&lt;key&gt;=&lt;value&gt; [&lt;tag&gt;=&lt;value&gt;]*"
_&lt;service&gt;._tcp.&lt;host&gt;  TXT "&lt;key&gt;=&lt;value&gt; [&lt;tag&gt;=&lt;value&gt;]*"</sourcecode>
<t>Where &lt;domain&gt; and &lt;host&gt; are the domain names specified in the corresponding SRV records.</t>
<t>Service descriptions specified under the domain address of the service apply to all host instances of the service. Descriptions specified under the domain address of a host instance apply only to that host instance and take precedence over values specified at the service level.</t>
<t>The following keys are currently defined:</t>
<dl>
<dt>path</dt>
<dd>
<t>The path to use to construct the Web Service Endpoint.</t>
</dd>
<dt>version</dt>
<dd>
<t>The service version(s) supported in the format &lt;max&gt;-&lt;min&gt;</t>
</dd>
<dt>encoding</dt>
<dd>
<t>An IANA media type specifying a supported encoding format</t>
</dd>
</dl>
</section>
</section>
<section title="Service Selection" anchor="n-service-selection"><t>Web Service Hosts that do not meet the requirements of the client attempting to create a connection are eliminated before applying SRV service selection criteria specified in <xref target="RFC2782"></xref>.</t>
<t>Clients <bcp14>SHOULD</bcp14> limit the number of connections attempted before abandoning the attempt to connect.</t>
</section>
<section title="Web Service Endpoint Determination" anchor="n-web-service-endpoint-determination"><t>Having selected a Web Service Host, the client determines the Web Service Endpoint as follows:</t>
<ul>
<li>If the description of the host specifies a path key, the corresponding value is used as the path, otherwise,</li>
<li>if the description of the service specifies a path key, the corresponding value is used as the path, otherwise,</li>
<li>the path is /.well-known/srv/&lt;service&gt;</li>
</ul>
</section>
<section title="DNS Fallback" anchor="n-dns-fallback"><t>Despite the fact that SRV records have been a part of the DNS standard for 20 years, it is not uncommon for network intermediaries to implement SRV record resolution incorrectly or block it entirely. If no SRV record is found, a client <bcp14>MAY</bcp14> perform fallback discovery if explicitly authorized to do so by the corresponding Web Service protocol specification.</t>
<t>The Web Service Endpoint used is:</t>
<sourcecode>https://&lt;service&gt;.&lt;domain&gt;/.well-known/srv/&lt;service&gt;</sourcecode>
<t>Fallback discovery constrains the service provider to use a specific DNS configuration and provides inferior load balancing or fault tolerance capabilities to use of SRV records. It does however ensure that the service is reachable in situations where it would otherwise be unavailable.</t>
</section>
<section title="Example" anchor="n-example"><t>The Mathematical Mesh has the Well-Known Service name of '<tt>MMM</tt>'.  Accounts used in the Mathematical Mesh follow the <xref target="RFC5322"></xref> format of &lt;user&gt;@&lt;domain&gt;. </t>
<t>Alice has the account alice@example.com and the DNS configuration file for example.com has the following entries:</t>
<sourcecode>_mmm._tcp.example.com SRV host1.example.com 0 10 80 host1.example.com
_mmm._tcp.example.com SRV host2.example.com 0 40 80 host2.example.com
_mmm._tcp.example.com TXT "version=1.0-2.0"
mmm.example.com       CNAME host3.example.com
host1.example.com     A 10.0.1.1
host2.example.com     A 10.0.1.2
_mmm._tcp.host2.example.com TXT "path=/service"
host3.example.com     A 10.0.1.1
host3.example.com     A 10.0.1.2</sourcecode>
<t> The client attempts to resolve the address alice@example.com as follows:</t>
<ol start="0">
<li>Client attempts to resolve SRV and TXT records for <tt>_mmm._tcp.example.com</tt></li>
<li>DNS resolver returns two SRV entries and one TXT entry</li>
<li>Client makes a random selection between host1 (20% weighting) and host2 (80% weighting). Chooses host1.</li>
<li>Client resolves A/AAAA for host1.example.com and TXT for <tt>_mmm._tcp.host1.example.com</tt></li>
<li>DNS resolver returns A=<tt>10.0.1.1</tt> and TXT=none</li>
<li>Client attempts to POST Web Service request to <tt>http://host1example.com/.well-known/srv/mmm</tt> at host address <tt>10.0.1.1</tt></li>
<li>The host at <tt>10.0.1.1</tt> returns 503 Service Unavailable</li>
<li>Client resolves A/AAAA for <tt>host2.example.com</tt> and TXT for <tt>_mmm._tcp.host2.example.com</tt></li>
<li>DNS resolver returns A=<tt>10.0.1.2</tt> and TXT <tt>"path=/service"</tt></li>
<li>Client attempts to POST Web Service request to <tt>http://host2example.com/service</tt> at host address <tt>10.0.1.2</tt></li>
<li>Request succeeds, session proceeds.</li>
</ol>
<t>If the same client is used in a network location where the SRV record resolution fails due to a faulty firewall configuration, the resolution proceeds as follows:</t>
<ol start="0">
<li>Client attempts to resolve SRV record for <tt>_mmm._tcp.example.com</tt></li>
<li>DNS resolver returns 'not found'</li>
<li>Client attempts to resolve A and AAAA record </li>
<li>DNS resolver returns <tt>10.0.1.1</tt>, <tt>10.0.1.2</tt></li>
<li>Client makes a random selection between <tt>10.0.1.1</tt> (50% weighting) and <tt>10.0.1.2</tt> (50% weighting). Chooses host1.</li>
<li>Client attempts to POST Web Service request to <tt>http://example.com/.well-known/srv/mmm</tt> at host address <tt>10.0.1.1</tt></li>
<li>The host at <tt>10.0.1.1</tt> returns 503 Service Unavailable</li>
<li>Client attempts to POST Web Service request to <tt>http://example.com/.well-known/srv/mmm</tt> at host address <tt>10.0.1.2</tt></li>
<li>Request succeeds, session proceeds.</li>
</ol>
<t>Note that the main differences between these two scenarios is that the use of the SRV record allows the service configuration to account for load balancing with tiers of fallback support and use of service description information while the use of round robin A/AAAA records does not.</t>
</section>
</section>
<section title="Further Work" anchor="n-further-work"><section title="Additional Description Keys" anchor="n-additional-description-keys"><t>The use of service and host descriptions to specify security enhancements is currently being considered. This provides a superset of the capabilities specified in <xref target="RFC6698"></xref>. </t>
<ul>
<li>Specify minimum TLS version.</li>
<li>Specify trust roots more flexibly</li>
<li>Specify client authentication requirements</li>
<li>Use of security enhancements other than TLS.</li>
<li>Publish public keys to be used to protect negotiation of security enhancements</li>
</ul>
<t>The use of service and host descriptions to specify use of non-HTTP presentation transports is currently being considered.</t>
</section>
<section title="Service Scaling" anchor="n-service-scaling"><t>This document considers the problem of establishing a connection to a Host providing a particular Web Service. When constructing services at very large scale (e.g. millions of concurrent users), it becomes desirable to enable discovery of a Web Service Host responsible for a particular partition of that data (e.g. a particular user account).</t>
<t>Since this is clearly a different problem, it is judged that the best approach is to give it a different name and rule it out of scope of the present work. </t>
</section>
</section>
<section title="Security Considerations" anchor="n-security-considerations"><t>A treatment of the security considerations will follow.</t>
</section>
<section title="IANA Considerations" anchor="n-iana-considerations"><t>The following registrations are required:</t>
<section title="Well-Known URIs" anchor="n-wellknown-uris"><t>The following registration is requested in the well-known URI registry in accordance with <xref target="RFC5785"></xref></t>
<t>URI suffix</t>
<t>srv</t>
<t>Change controller</t>
<t>Phillip Hallam-Baker, phill@hallambaker.com</t>
<t>Specification document(s):</t>
<t>[This document]</t>
<t>Related information</t>
<t><xref target="draft-hallambaker-web-service-discovery"></xref></t>
<dl>
<dt></dt>
<dd>
<t></t>
</dd>
</dl>
</section>
</section>
</middle>
<back>
<references title="Normative References"><reference anchor="RFC6763"><front>
<title>DNS-Based Service Discovery</title>
<author fullname="S. Cheshire" initials="S." surname="Cheshire"><organization/>
<address>
</address>
</author>
<author fullname="M. Krochmal" initials="M." surname="Krochmal"><organization/>
<address>
</address>
</author>
<date month="February" year="2013"/>
</front>
<seriesInfo name="RFC" value="6763"/>
<seriesInfo name="DOI" value="10.17487/RFC6763"/>
</reference>
<reference anchor="RFC5785"><front>
<title>Defining Well-Known Uniform Resource Identifiers (URIs)</title>
<author fullname="M. Nottingham" initials="M." surname="Nottingham"><organization/>
<address>
</address>
</author>
<author fullname="E. Hammer-Lahav" initials="E." surname="Hammer-Lahav"><organization/>
<address>
</address>
</author>
<date month="April" year="2010"/>
</front>
<seriesInfo name="RFC" value="5785"/>
<seriesInfo name="DOI" value="10.17487/RFC5785"/>
</reference>
<reference anchor="RFC3986"><front>
<title>Uniform Resource Identifier (URI): Generic Syntax</title>
<author fullname="T. Berners-Lee" initials="T." surname="Berners-Lee"><organization/>
<address>
</address>
</author>
<author fullname="R. Fielding" initials="R." surname="Fielding"><organization/>
<address>
</address>
</author>
<author fullname="L. Masinter" initials="L." surname="Masinter"><organization/>
<address>
</address>
</author>
<date month="January" year="2005"/>
</front>
<seriesInfo name="STD" value="66"/>
<seriesInfo name="RFC" value="3986"/>
<seriesInfo name="DOI" value="10.17487/RFC3986"/>
</reference>
<reference anchor="RFC2782"><front>
<title>A DNS RR for specifying the location of services (DNS SRV)</title>
<author fullname="A. Gulbrandsen" initials="A." surname="Gulbrandsen"><organization/>
<address>
</address>
</author>
<author fullname="P. Vixie" initials="P." surname="Vixie"><organization/>
<address>
</address>
</author>
<author fullname="L. Esibov" initials="L." surname="Esibov"><organization/>
<address>
</address>
</author>
<date month="February" year="2000"/>
</front>
<seriesInfo name="RFC" value="2782"/>
<seriesInfo name="DOI" value="10.17487/RFC2782"/>
</reference>
</references>
<references title="Informative References"><reference anchor="RFC5322"><front>
<title>Internet Message Format</title>
<author fullname="P. Resnick" initials="P." surname="Resnick"><organization/>
<address>
</address>
</author>
<date month="October" year="2008"/>
</front>
<seriesInfo name="RFC" value="5322"/>
<seriesInfo name="DOI" value="10.17487/RFC5322"/>
</reference>
<reference anchor="RFC6698"><front>
<title>The DNS-Based Authentication of Named Entities (DANE) Transport Layer Security (TLS) Protocol: TLSA</title>
<author fullname="P. Hoffman" initials="P." surname="Hoffman"><organization/>
<address>
</address>
</author>
<author fullname="J. Schlyter" initials="J." surname="Schlyter"><organization/>
<address>
</address>
</author>
<date month="August" year="2012"/>
</front>
<seriesInfo name="RFC" value="6698"/>
<seriesInfo name="DOI" value="10.17487/RFC6698"/>
</reference>
<reference anchor="draft-hallambaker-web-service-discovery"><front>
<title>DNS Web Service Discovery</title>
<author fullname="Phillip Hallam-Baker" initials="P." surname="Hallam-Baker"><address>
</address>
</author>
<date day="28" month="June" year="2023"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-hallambaker-web-service-discovery-09"/>
</reference>
</references>
</back>
</rfc>
