Trust-anchors is a term that is defined in the X.509 specifications, currently documented in RFC 5280. In general a trust anchor is simply defined as a certificate at the start of a trust path. For browsers the trust anchors are usually consist of the set of root certificates. In Java this is mimicked by the standard cacerts file that is delivered as part of the Java runtime. This file is used by e.g. the SSL/TLS services offered by the Java JSSE provider.
However, it is perfectly possible and quite often advantageous to limit the trust that you extend to certificates. In the most simple case it might be that you don't want to trust all the root certificates stored in the cacerts file. You may just want to trust a single root certificate, an underlying (intermediate) CA certificate or - in the extreme case - just the certificate used to authenticate a particular server (certificate pinning).
For this reason you can offer a set of certificates to a CertPathValidator
which validates the chain of certificates. This CertPathValidator
is an abstract class that could handle any kind of certificates. The Java runtime however contains just the single, mandated implementation "PKIX", which indicates a Public Key Infrastructure consisting of X.509 certificates (the X in the acronym).
This PKIXValidator
service implementation in turn can be configured using the PKIXParameters
class. This class has constructors and "setters" to indicate the trust anchors. This usually consists of a "trust store", i.e. a key store containing trusted certificates. The cacerts
file would be the default trust store used by the PKIXValidator
used by the JSSE provider.
Alternatively a Set
of TrustAnchor
instances can be provided. A trust anchor usually just consists of a certificate and optional "name constraints". However, it may also just contain a description of a certificate, such as the name and public key of a certificate. This would e.g. allow you to "pin" a specific public key / name combination while allowing the other party to update their certificate.
It goes a bit far to dive deep into the encoding of the name constraints, but in short the DNS names or IP address within the subject field of a particular certificates in a certificate tree may be validated using these. The parameter may be null
if no particular constrains are required. The procedure to validate the name constrains is of course also indicated in RFC 5280.
Note that documentation of (older) Java versions may refer to the now obsolete RFC 3280 instead of RFC 5280.