Code example for X509Certificate

Methods: getSubjectX500Principal

     * caller can disambiguate these cases by calling {@code 
     * File.exists()} on the result. 
    private File getCertificateFile(File dir, final X509Certificate x) {
        // compare X509Certificate.getEncoded values 
        CertSelector selector = new CertSelector() {
            @Override public boolean match(X509Certificate cert) {
                return cert.equals(x);
        return findCert(dir, x.getSubjectX500Principal(), selector, File.class);
     * This non-{@code KeyStoreSpi} public interface is used by {@code 
     * TrustManagerImpl} to locate a CA certificate with the same name 
     * and public key as the provided {@code X509Certificate}. We 
     * match on the name and public key and not the entire certificate 
     * since a CA may be reissued with the same name and PublicKey but 
     * with other differences (for example when switching signature