ks.setCertificateEntry("ca2", createPath(c2)[0]);
Validator v = Validator.getInstance
(Validator.TYPE_PKIX, Validator.VAR_GENERIC, ks);
// Validating chain (u1, c1)
X509Certificate[] chain1 = createPath(u1 + c1);
for (X509Certificate c: v.validate(chain1)) {
System.out.println(" " + c.getSubjectX500Principal() +
" issued by " + c.getIssuerX500Principal());
}
// Validating chain (u2, c2)
X509Certificate[] chain2 = createPath(u2 + c2);