Code example for TrustAnchor

0
        try { 
            bis = new BufferedInputStream(new ByteArrayInputStream(
                    getEncodedX509Certificate())); 
            X509Certificate c1 = (X509Certificate)cf.generateCertificate(bis);
 
            return new TrustAnchor(c1, null);
        } catch (Exception e) {
            // all failures are fatal 
            throw new RuntimeException(e);
        } finally { 
            if (bis != null) {
                try { 
                    bis.close() ;
                } catch (IOException ign) {}
            } 
        } 
    } 
 
    /** 
     * Creates <code>Set</code> of <code>TrustAnchor</code>s 
     * containing single element (self signed test certificate).