private boolean isCertKnown(X509Certificate cert) { try { return appKeyStore.getCertificateAlias(cert) != null; } catch (KeyStoreException e) { LOGGER.log(Level.FINE, e.toString()); return false; } }
private HttpClient getHttpClient() { HttpClientBuilder builder = HttpClientBuilder.create().useSystemProperties(); if (this.ignoreSsl) { try { SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); sslContextBuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContextBuilder.build(), NoopHostnameVerifier.INSTANCE); builder.setSSLSocketFactory(sslsf); } catch (NoSuchAlgorithmException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } catch (KeyStoreException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } catch (KeyManagementException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } } return builder.build(); }
throw new IOException(kse.toString(), kse);
private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setButtonActionPerformed int ks = keyStoreList.getSelectedIndex(); int alias = aliasTable.getSelectedRow(); String fingerprint = ""; if (ks > -1 && alias>-1) { if (!_certRepo.isKeyUnlocked(ks, alias)) { String password = getPassword(); try { _certRepo.unlockKey(ks, alias, password); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, new String[] {"Error accessing key store: ", e.toString()}, "Error", JOptionPane.ERROR_MESSAGE); } } Certificate cert = _certRepo.getCertificate(ks, alias); try { fingerprint = _certRepo.getFingerPrint(cert); } catch (KeyStoreException kse) { kse.printStackTrace(); JOptionPane.showMessageDialog(null, new String[] {"Error calculating key fingerprint: ", kse.toString()}, "Error", JOptionPane.ERROR_MESSAGE); fingerprint = ""; } } currentCertTextField.setText(fingerprint); _certRepo.setDefaultKey(fingerprint); }//GEN-LAST:event_setButtonActionPerformed
@Override public void addCertificate(X509Certificate certificate) throws KeyManagementException { keystore.addTrustedSslCertificate(certificate, certificate.getSubjectX500Principal().getName()); try { keystore.save(); } catch(KeyStoreException e) { throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e); } catch(IOException e) { throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e); } catch(NoSuchAlgorithmException e) { throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e); } catch(CertificateException e) { throw new KeyManagementException("Cannot add certificate to keystore: "+e.toString(), e); } hashCode = null; // signal to recalculate the hashcode due to changed contents } /*
contextManager.getFingerPrint(cert); } catch (KeyStoreException kse) { showCertError("options.cert.error.fingerprint", kse.toString());
throw new LscServiceConfigurationException(e.toString(), e); } catch (KeyStoreException e) { throw new LscServiceConfigurationException(e.toString(), e);