valid_hostname() rejects strings that start or end with a dot. This method was introduced in a625b39 for CDRIVER-2257. As discussed in mongodb/mongo-php-driver#968, section 3.2.2 of RFC3986 states:
Such a name consists of a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumeric character and possibly also containing "-" characters. The rightmost domain label of a fully qualified domain name in DNS may be followed by a single "." and should be if it is necessary to distinguish between the complete domain name and some local domain.
Between this and the grammar definitions in Collected ABNF for URI, it looks like a trailing dot is permitted in a valid host string. I'm not sure if libmongoc is alone in disallowing trailing dots in its valid_hostname() function, which is used for general URI parsing and DNS seedlist discovery (SRV).
The structure of a hostname not explicitly addressed in the SRV or Connection String specs, but Connection String: Host does reference RFC3986 as the authority on host strings.
- is related to
-
SERVER-31965 Mongo Shell does not handle FQDN from SRV target values correctly
- Closed
-
CDRIVER-2257 Initial DNS Seedlist discovery
- Closed
- related to
-
DRIVERS-2057 Determine how drivers should handle trailing dots in SRV results
- Backlog
-
DRIVERS-2087 Test parsing of hosts with trailing dots
- Backlog
- links to