public boolean engineIsCertificateEntry(final String alias) { try { return delegate.isCertificateEntry(alias); } catch (KeyStoreException e) { return false; } }
@Override public boolean engineIsCertificateEntry(String alias) { try { return getKeyStore().isCertificateEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
public OpenfireX509TrustManager( KeyStore trustStore, boolean acceptSelfSigned, boolean checkValidity ) throws NoSuchAlgorithmException, KeyStoreException { this.acceptSelfSigned = acceptSelfSigned; this.checkValidity = checkValidity; // Retrieve all trusted certificates from the store, but don't validate them just yet! final Set<X509Certificate> trusted = new HashSet<>(); final Enumeration<String> aliases = trustStore.aliases(); while ( aliases.hasMoreElements() ) { final String alias = aliases.nextElement(); if ( trustStore.isCertificateEntry( alias ) ) { final Certificate certificate = trustStore.getCertificate( alias ); if ( certificate instanceof X509Certificate ) { trusted.add( (X509Certificate) certificate ); } } } trustedIssuers = Collections.unmodifiableSet( trusted ); Log.debug( "Constructed trust manager. Number of trusted issuers: {}, accepts self-signed: {}, checks validity: {}", trustedIssuers.size(), acceptSelfSigned, checkValidity ); }
static List<X509Certificate> loadCertificates(KeyStore keyStore) { List<X509Certificate> certs = new LinkedList<>(); try { Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isCertificateEntry(alias)) { X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias); certs.add(cert); LOGGER.finest(() -> "Added certificate under alis " + alias + " for " + cert .getSubjectDN() + " to list of certificates"); } } } catch (KeyStoreException e) { throw new PkiException("Failed to load certificates from keystore: " + keyStore, e); } return certs; } }
String alias = en.nextElement(); Certificate cert = ks.getCertificate(alias); if (ks.isCertificateEntry(alias) && ! alias.startsWith(DUMMY_CERT_ALIAS)){ final KeyStore keyStore = createEmptyKeyStore(); keyStore.setCertificateEntry("cert-1", cert);
for (Enumeration i = keyStore.aliases(); i.hasMoreElements();) { String alias = (String) i.nextElement(); if (keyStore.isCertificateEntry(alias)) {
while (aliases.hasMoreElements()) { final String alias = aliases.nextElement(); if (keyStore.isCertificateEntry(alias)) { final Certificate certificate = keyStore.getCertificate(alias); if (certificate instanceof X509Certificate && x500Principal.equals(X500PrincipalUtil.asX500Principal(((X509Certificate) certificate).getSubjectX500Principal()))) {
if ( store.isCertificateEntry( alias ) )
/** * Count all X509 Certs in a key store * * @return number successfully added * @since 0.8.2, moved from SSLEepGet in 0.9.9 */ public static int countCerts(KeyStore ks) { int count = 0; try { for(Enumeration<String> e = ks.aliases(); e.hasMoreElements();) { String alias = e.nextElement(); if (ks.isCertificateEntry(alias)) { //info("Found cert " + alias); count++; } } } catch (GeneralSecurityException e) {} return count; }
private static Set<TrustAnchor> getTrustAnchorsFromKeyStore(KeyStore keyStore) throws GeneralSecurityException { Enumeration<String> aliases = keyStore.aliases(); HashSet<TrustAnchor> trustAnchors = new HashSet<>(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isCertificateEntry(alias)) { trustAnchors.add(new TrustAnchor((X509Certificate) keyStore.getCertificate(alias), null)); } } return trustAnchors; }
String alias = en.nextElement(); Certificate cert = ks.getCertificate(alias); if (ks.isCertificateEntry(alias) && ! alias.startsWith(DUMMY_CERT_ALIAS)){ final KeyStore keyStore = createEmptyKeyStore(); keyStore.setCertificateEntry("cert-1", cert);
for(Enumeration<String> e = ks.aliases(); e.hasMoreElements();) { String alias = e.nextElement(); if (ks.isCertificateEntry(alias)) { Certificate c = ks.getCertificate(alias); if (c != null && (c instanceof X509Certificate)) {
@Override public ManagerFactoryParameters configFor(KeyStore trustStore, Set<TrustAnchor> defaultTrustAnchors) { checkArgument(url != null, "tls:custom-ocsp-responder requires the 'url' attribute"); checkArgument(trustStore != null, "tls:custom-ocsp-responder requires a trust store"); try { CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX"); PKIXRevocationChecker rc = (PKIXRevocationChecker) cpb.getRevocationChecker(); rc.setOptions(EnumSet.of(PKIXRevocationChecker.Option.NO_FALLBACK)); if (url != null) { rc.setOcspResponder(new URI(url)); } if (certAlias != null) { if (trustStore.isCertificateEntry(certAlias)) { rc.setOcspResponderCert((X509Certificate) trustStore.getCertificate(certAlias)); } else { throw new IllegalStateException("Key with alias \"" + certAlias + "\" was not found"); } } PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustStore, new X509CertSelector()); pkixParams.addCertPathChecker(rc); return new CertPathTrustManagerParameters(pkixParams); } catch (GeneralSecurityException | URISyntaxException e) { throw new RuntimeException(e); } }
public boolean engineIsCertificateEntry(final String alias) { try { return delegate.isCertificateEntry(alias); } catch (KeyStoreException e) { return false; } }
public boolean engineIsCertificateEntry(final String alias) { try { return delegate.isCertificateEntry(alias); } catch (KeyStoreException e) { return false; } }
private void addFromKeyStore(KeyStore keyStore) throws Exception { for (Enumeration<String> enumeration = keyStore.aliases(); enumeration.hasMoreElements(); ) { String alias = enumeration.nextElement(); if (keyStore.isCertificateEntry(alias)) { certificates.add(keyStore.getCertificate(alias)); } } } }
@Override public boolean engineIsCertificateEntry(String alias) { try { return getKeyStore().isCertificateEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
@Override public boolean engineIsCertificateEntry(String alias) { try { return getKeyStore().isCertificateEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }
private static Set<TrustAnchor> getTrustAnchorsFromKeyStore(KeyStore keyStore) throws GeneralSecurityException { Enumeration<String> aliases = keyStore.aliases(); HashSet<TrustAnchor> trustAnchors = new HashSet<>(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isCertificateEntry(alias)) { trustAnchors.add(new TrustAnchor((X509Certificate) keyStore.getCertificate(alias), null)); } } return trustAnchors; }
@Override public boolean engineIsCertificateEntry(String alias) { try { return getKeyStore().isCertificateEntry(alias); } catch (KeyStoreException e) { throw new IllegalStateException(e); } }