public void close() { try { reader.close(); } catch (Throwable th) { LogUtil.error(LOG, th,"could not close reader"); } }
private SignedData getCert(X509Ca ca, BigInteger serialNumber) throws FailInfoException, OperationException { X509Certificate cert; try { cert = ca.getCert(serialNumber); } catch (CertificateException ex) { final String message = "could not get certificate for CA '" + caIdent + "' and serialNumber=" + LogUtil.formatCsn(serialNumber) + ")"; LogUtil.error(LOG, ex, message); throw new OperationException(ErrorCode.SYSTEM_FAILURE, ex); } if (cert == null) { throw FailInfoException.BAD_CERTID; } return buildSignedData(cert); } // method getCert
private static void closeWriter(Writer writer) { try { writer.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not close writer"); } }
entry = queue.take(); } catch (InterruptedException ex) { LogUtil.error(LOG, ex, "could not take from queue"); failed = true; break; queue.put(entry); } catch (InterruptedException ex) { LogUtil.warn(LOG, ex, "could not re-add EndOfQueue to queue"); certInfo = certstore.getCertForId(ca, caCert, sid.getId(), caIdNameMap); } catch (OperationException | CertificateException ex) { LogUtil.error(LOG, ex); failed = true; break; if (!successful) { LOG.error("republish certificate serial={} to publisher {} failed", LogUtil.formatCsn(sid.getSerial()), publisher.getIdent()); allSucc = false;
static String formatCert(X509Certificate cert, boolean verbose) { if (cert == null) { return " null"; } StringBuilder sb = new StringBuilder(verbose ? 1000 : 100); sb.append(" issuer: ") .append(X509Util.getRfc4519Name(cert.getIssuerX500Principal())).append('\n'); sb.append(" serialNumber: ").append(LogUtil.formatCsn(cert.getSerialNumber())).append('\n'); sb.append(" subject: ") .append(X509Util.getRfc4519Name(cert.getSubjectX500Principal())).append('\n'); sb.append(" notBefore: ").append(cert.getNotBefore()).append("\n"); sb.append(" notAfter: ").append(cert.getNotAfter()); if (verbose) { sb.append("\n encoded: "); try { sb.append(Base64.encodeToString(cert.getEncoded())); } catch (CertificateEncodingException ex) { sb.append("ERROR"); } } return sb.toString(); }
private CertWithDbId removeCert0(BigInteger serialNumber, AuditEvent event) throws OperationException { event.addEventData(CaAuditConstants.NAME_serial, LogUtil.formatCsn(serialNumber)); CertWithRevocationInfo certWithRevInfo = certstore.getCertWithRevocationInfo(caIdent.getId(), serialNumber, caIdNameMap); } catch (RuntimeException ex) { singleSuccessful = false; LogUtil.warn(LOG, ex, "could not remove certificate from the publisher " + publisher.getIdent()); LOG.error("removing certificate issuer='{}', serial={}, subject='{}' from publisher" + " {} failed.", X509Util.getRfc4519Name(cert.getIssuerX500Principal()), LogUtil.formatCsn(cert.getSerialNumber()), X509Util.getRfc4519Name(cert.getSubjectX500Principal()), publisher.getIdent());
LOG.info("{} generateCertificate: CA={}, profile={}, subject='{}', serialNumber={}", prefix, caIdent.getName(), certprofilIdent.getName(), cert.getSubject(), LogUtil.formatCsn(cert.getCert().getSerialNumber())); removeCert(serial, msgId); } catch (Throwable thr) { LogUtil.error(LOG, thr, "could not delete certificate serial=" + serial); LogUtil.warn(LOG, exception); throw exception;
ca.close(); } catch (Throwable th) { LogUtil.error(LOG, th, concat("could not call ca.shutdown() for CA ", caName)); unlockCa(); } catch (Throwable th) { LogUtil.error(LOG, th, "could not unlock CA system"); datasource.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, concat("could not close datasource ca"));
static String formatCert(X509Certificate cert, boolean verbose) { if (cert == null) { return " null"; } StringBuilder sb = new StringBuilder(verbose ? 1000 : 100); sb.append(" issuer: ") .append(X509Util.getRfc4519Name(cert.getIssuerX500Principal())).append('\n'); sb.append(" serialNumber: ").append(LogUtil.formatCsn(cert.getSerialNumber())).append('\n'); sb.append(" subject: ") .append(X509Util.getRfc4519Name(cert.getSubjectX500Principal())).append('\n'); sb.append(" notBefore: ").append(cert.getNotBefore()).append("\n"); sb.append(" notAfter: ").append(cert.getNotAfter()); if (verbose) { sb.append("\n encoded: "); try { sb.append(Base64.encodeToString(cert.getEncoded())); } catch (CertificateEncodingException ex) { sb.append("ERROR"); } } return sb.toString(); }
@Override public void close() { try { reader.close(); } catch (Throwable th) { LogUtil.error(LOG, th,"could not close reader"); } }
private CertWithDbId unrevokeCert0(BigInteger serialNumber, boolean force, AuditEvent event) throws OperationException { String hexSerial = LogUtil.formatCsn(serialNumber); event.addEventData(CaAuditConstants.NAME_serial, hexSerial); } catch (RuntimeException ex) { successful = false; LogUtil.error(LOG, ex, "could not publish unrevocation of certificate to the publisher " + publisher.getIdent().getName()); certstore.addToPublishQueue(publisher.getIdent(), certId.longValue(), caIdent); } catch (Throwable th) { LogUtil.error(LOG, th, "could not add entry to PublishQueue");
certIds = certstore.getPublishQueueEntries(caIdent, publisher.getIdent(), numEntries); } catch (OperationException ex) { LogUtil.error(LOG, ex); return false; certInfo = certstore.getCertForId(caIdent, caCert, certId, caIdNameMap); } catch (OperationException | CertificateException ex) { LogUtil.error(LOG, ex); return false; certstore.removeFromPublishQueue(publisher.getIdent(), certId); } catch (OperationException ex) { LogUtil.warn(LOG, ex, "could not remove republished cert id=" + certId + " and publisher=" + publisher.getIdent().getName()); continue;
private static void formatString(Integer index, boolean verbose, StringBuilder sb, X509Certificate cert) { String subject = X509Util.getRfc4519Name(cert.getSubjectX500Principal()); sb.append("\t\tCertificate"); if (index != null) { sb.append("[").append(index).append("]"); } sb.append(": "); if (!verbose) { sb.append(subject).append("\n"); return; } sb.append("\n\t\t\tSubject: ").append(subject); String issuer = X509Util.getRfc4519Name(cert.getIssuerX500Principal()); sb.append("\n\t\t\tIssuer: ").append(issuer); sb.append("\n\t\t\tSerial: ").append(LogUtil.formatCsn(cert.getSerialNumber())); sb.append("\n\t\t\tStart time: ").append(cert.getNotBefore()); sb.append("\n\t\t\tEnd time: ").append(cert.getNotAfter()); sb.append("\n\t\t\tSHA1 Sum: "); try { sb.append(HashAlgo.SHA1.hexHash(cert.getEncoded())); } catch (CertificateEncodingException ex) { sb.append("ERROR"); } sb.append("\n"); }
private static void closeWriter(Writer writer) { try { writer.close(); } catch (Exception ex) { LogUtil.warn(LOG, ex, "could not close writer"); } }
public void returnConnection(Connection conn) { if (conn == null) { return; } try { conn.close(); } catch (Exception ex) { Throwable cause = ex.getCause(); if (cause instanceof SQLException) { ex = (SQLException) cause; } LogUtil.error(LOG, ex, "could not close connection to database {}"); } }
private CertWithRevocationInfo revokeSuspendedCert0(BigInteger serialNumber, CrlReason reason, AuditEvent event) throws OperationException { String hexSerial = LogUtil.formatCsn(serialNumber); } catch (RuntimeException ex) { successful = false; LogUtil.error(LOG, ex, "could not publish revocation of certificate to the publisher " + publisher.getIdent().getName()); certstore.addToPublishQueue(publisher.getIdent(), certId.longValue(), caIdent); } catch (Throwable th) { LogUtil.error(LOG, th, "could not add entry to PublishQueue");
} catch (RuntimeException ex) { successful = false; LogUtil.warn(LOG, ex, "could not publish certificate to the publisher " + publisher.getIdent()); certstore.addToPublishQueue(publisher.getIdent(), certId.longValue(), caIdent); } catch (Throwable th) { LogUtil.error(LOG, th, "could not add entry to PublishQueue"); return 2;
private static void formatString(Integer index, boolean verbose, StringBuilder sb, X509Certificate cert) { String subject = X509Util.getRfc4519Name(cert.getSubjectX500Principal()); sb.append("\t\tCertificate"); if (index != null) { sb.append("[").append(index).append("]"); } sb.append(": "); if (!verbose) { sb.append(subject).append("\n"); return; } sb.append("\n\t\t\tSubject: ").append(subject); String issuer = X509Util.getRfc4519Name(cert.getIssuerX500Principal()); sb.append("\n\t\t\tIssuer: ").append(issuer); sb.append("\n\t\t\tSerial: ").append(LogUtil.formatCsn(cert.getSerialNumber())); sb.append("\n\t\t\tStart time: ").append(cert.getNotBefore()); sb.append("\n\t\t\tEnd time: ").append(cert.getNotAfter()); sb.append("\n\t\t\tSHA1 Sum: "); try { sb.append(HashAlgo.SHA1.hexHash(cert.getEncoded())); } catch (CertificateEncodingException ex) { sb.append("ERROR"); } sb.append("\n"); }