The CA selection is approximately this:
Without Enrollment Policy Service:
- Get all enterprise CAs from AD and create List1
- Select CAs that have requested certificate templates and create List2
- If List2 is empty, stop processing
- Select CAs that are site-aware and match client site and create List3
- if resulting List3 is empty, use list obtained in step 2 and create List3
- randomize List3 and pick arbitrary CA
With Enrollment Policy Service:
- build a list of Policy Servers using: Group Policy, local cache, locally configured policies
- order policy servers in ascending order by Cost property. Policy servers with lower cost will be tried first
- Iterate over Policy Server list and for each server:
- Get list of CAs advertised by policy server and create List1
- Select CAs that have requested certificate templates and create List2
- If List2 is empty, continue with next Policy Server
6.1. If there is no next Policy Server, return error - Order List2 by Cost property. CAs with lower cost will be tried first.
this is very high-level flow on a client.