Date end = null; Principal principal = null; for (X509Certificate c : chain.getChain())
private X509Certificate[] createProxyCertChain(X509Certificate cert) { AccessControlContext ac = AccessController.getContext(); Subject subject = Subject.getSubject(ac); if (subject != null) { Set<X509CertificateChain> cc = subject.getPublicCredentials(X509CertificateChain.class); if (cc.size() > 0) { X509CertificateChain xcc = cc.iterator().next(); X509Certificate[] chain = xcc.getChain(); X509Certificate[] ret = new X509Certificate[chain.length + 1]; ret[0] = cert; for (int i=0; i<chain.length; i++) { ret[i+1] = chain[i]; } return ret; } } throw new IllegalStateException("current Subject does not contain a certficate chain"); }
for (X509Certificate c : chain.getChain())
public static SSLSocketFactory getSocketFactory(X509CertificateChain chain) { KeyStore ts = null; KeyStore ks = null; if (chain != null) ks = getKeyStore(chain.getChain(), chain.getPrivateKey()); return getSocketFactory(ks, ts); }
/** * @param chain certificate * @param writer writer use to write the generated PEM certificate * @throws IOException */ public static void writePEMCertificateAndKey( X509CertificateChain chain, Writer writer) throws IOException { if (chain == null) throw new IllegalArgumentException("Null certificate chain"); if (writer == null) throw new IllegalArgumentException("Null writer"); PEMWriter pemWriter = new PEMWriter(writer); // write the first certificate first pemWriter.writeObject(chain.getChain()[0]); // then the key pemWriter.writeObject(chain.getPrivateKey()); // and finally the rest of the certificates in the chain for (int i = 1; i < chain.getChain().length; i++) { pemWriter.writeObject(chain.getChain()[i]); } pemWriter.flush(); } }
Date start = null; Date end = null; for (X509Certificate c : chain.getChain())
for (X509Certificate c : chain.getChain())