private KeyStore initKeyStore(String keystoreFile, String keyPass) throws IOException { java.io.InputStream istream = null; KeyStore kstore; try { kstore = KeyStore.getInstance("JKS"); istream = new FileInputStream(keystoreFile); kstore.load(istream, keyPass.toCharArray()); return kstore; } catch (KeyStoreException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } catch (CertificateException e) { throw new IOException(e.getMessage()); } }
private void writeCertificateFile() throws CertificateException { java.io.OutputStream keyStoreStream = null; try { keyStoreStream = new java.io.FileOutputStream(keyStoreFile); keyStore.store(keyStoreStream, "".toCharArray()); } catch (FileNotFoundException e) { throw new CertificateException("Unable to write KeyStore: " + e.getMessage()); } catch (CertificateException e) { throw new CertificateException("Unable to write KeyStore: " + e.getMessage()); } catch (IOException e) { throw new CertificateException("Unable to write KeyStore: " + e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new CertificateException("Unable to write KeyStore: " + e.getMessage()); } catch (KeyStoreException e) { throw new CertificateException("Unable to write KeyStore: " + e.getMessage()); } finally { IOUtils.closeQuietly(keyStoreStream); } }
public boolean calls() { boolean isRet = false; //https try { this.callHttps(); isRet = true; } catch (UnrecoverableKeyException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (KeyManagementException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (CertificateException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (KeyStoreException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (NoSuchAlgorithmException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (IOException e) { _log.error("", e); this.errInfo = e.getMessage(); } catch (Exception e) { _log.error("", e); this.errInfo = e.getMessage(); } return isRet; }
Log.error(e.getMessage(), e);
/** * validates a specific alias inside of the keystore being passed in * * @param keyStore the keystore to validate * @param keyAlias the keyalias in the keystore to valid with * @return the keyAlias if valid * @throws CertificateException if keystore error and unable to validate */ public String validate(KeyStore keyStore, String keyAlias) throws CertificateException { String result = null; if (keyAlias != null) { try { validate(keyStore, keyStore.getCertificate(keyAlias)); } catch (KeyStoreException kse) { LOG.debug(kse); throw new CertificateException("Unable to validate certificate" + " for alias [" + keyAlias + "]: " + kse.getMessage(), kse); } result = keyAlias; } return result; }
(certAlias == null ? "":" for alias [" +certAlias + "]") + ": " + kse.getMessage(), kse);
public static HttpClient getHttpClient() { HttpClient httpClient = null; TrustStrategy easyStrategy = new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }; try { SSLSocketFactory sf = new SSLSocketFactory(easyStrategy, new AllowAllHostnameVerifier()); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", DEFAULT_PORT, sf)); ClientConnectionManager ccm = new BasicClientConnectionManager(registry); httpClient = new DefaultHttpClient(ccm); } catch (KeyManagementException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (UnrecoverableKeyException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (NoSuchAlgorithmException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } catch (KeyStoreException e) { s_logger.error("failed to initialize http client " + e.getMessage()); } return httpClient; }
s_logger.error("failed to initialize http client " + e.getMessage()); } catch (final KeyStoreException e) { s_logger.error("failed to initialize http client " + e.getMessage());
s_logger.error("failed to initialize http client " + e.getMessage()); } catch (KeyStoreException e) { s_logger.error("failed to initialize http client " + e.getMessage());
String emsg = "Unable to add CA certificate to trust store. Error: " + e.getMessage(); logger.error(emsg, e); throw new CryptoException(emsg, e);
throw CommandExecutionException.builder() .withCause(e) .withMessage("Unable to build a keystore instance: " + e.getMessage()) .build();
/** * Returns a {@link KeyStore} instance of type jks * * @return a {@link KeyStore} instance * @throws AssertionError only if the JVM does not support jks type which means the JVM is not supported for Terracotta */ public static KeyStore getKeyStoreInstance() { try { return KeyStore.getInstance(KEY_STORE_TYPE); } catch (KeyStoreException e) { throw new AssertionError("JKS KeyStore type not supported and required by Terracotta in SSL mode (" + e.getMessage()+")"); } }
public Certificate getTrustAnchor(String alias) throws IOException, GeneralSecurityException { if (alias == null) { throw new IllegalArgumentException("Alias must be specified"); //$NON-NLS-1$ } try { KeyStore store = getKeyStore(); synchronized (store) { return store.getCertificate(alias); } } catch (KeyStoreException ke) { throw (CertificateException) new CertificateException(ke.getMessage()).initCause(ke); } }
public Certificate getTrustAnchor(String alias) throws IOException, GeneralSecurityException { if (alias == null) { throw new IllegalArgumentException("Alias must be specified"); //$NON-NLS-1$ } try { KeyStore store = getKeyStore(); synchronized (store) { return store.getCertificate(alias); } } catch (KeyStoreException ke) { throw (CertificateException) new CertificateException(ke.getMessage()).initCause(ke); } }
public Certificate getTrustAnchor(String alias) throws IOException, GeneralSecurityException { if (alias == null) { throw new IllegalArgumentException("Alias must be specified"); //$NON-NLS-1$ } try { KeyStore store = getKeyStore(); synchronized (store) { return store.getCertificate(alias); } } catch (KeyStoreException ke) { throw (CertificateException) new CertificateException(ke.getMessage()).initCause(ke); } }
public Certificate getTrustAnchor(String alias) throws IOException, GeneralSecurityException { if (alias == null) { throw new IllegalArgumentException("Alias must be specified"); //$NON-NLS-1$ } try { KeyStore store = getKeyStore(); synchronized (store) { return store.getCertificate(alias); } } catch (KeyStoreException ke) { throw (CertificateException) new CertificateException(ke.getMessage()).initCause(ke); } }
public static X509Certificate getCertificate(Certificado certificado, KeyStore keystore) throws CertificadoException { try { return (X509Certificate) keystore.getCertificate(certificado.getNome()); } catch (KeyStoreException e) { throw new CertificadoException("Erro Ao pegar X509Certificate: " + e.getMessage()); } }
public static X509Certificate getCertificate(Certificado certificado, KeyStore keystore) throws CertificadoException { try { return (X509Certificate) keystore.getCertificate(certificado.getNome()); } catch (KeyStoreException e) { throw new CertificadoException("Erro Ao pegar X509Certificate: " + e.getMessage()); } }
@Override public boolean isKeystoreContainAlias(String alias) throws PFSecurityException { final KeyStore keyStore = loadKeyStore(); try { return keyStore.containsAlias(alias); } catch (KeyStoreException e) { e.printStackTrace(); throw new PFSecurityException(e.getMessage()); } }
@Override public boolean isKeystoreContainAlias(String alias) throws PFSecurityException { final KeyStore keyStore = loadKeyStore(); try { return keyStore.containsAlias(alias); } catch (KeyStoreException e) { e.printStackTrace(); throw new PFSecurityException(e.getMessage()); } }