Beispiel #1
0
  public static X509CertificateObject getCertificate() {
    if (cert == null) {
      try {

        File f = new File(XMPConfig.getCertfile());
        FileReader fr;
        fr = new FileReader(f);

        PEMReader r = new PEMReader(fr);
        Object o = r.readObject();
        if (o instanceof X509CertificateObject) {
          cert = (X509CertificateObject) o;
        }
        cert.checkValidity();
        r.close();
      } catch (FileNotFoundException e) {
        logger.error("FATAL: couldn't load certificate file", e);
        System.exit(1);
      } catch (NullPointerException e) {
        logger.error("FATAL: couldn't load certificate file", e);
        System.exit(1);
      } catch (IOException e) {
        logger.error("FATAL: couldn't load certificate file", e);
        System.exit(1);
      } catch (CertificateExpiredException e) {
        logger.error("FATAL: couldn't load certificate file", e);
        System.exit(1);
      } catch (CertificateNotYetValidException e) {
        logger.error("FATAL: couldn't load certificate file", e);
        System.exit(1);
      }
    }
    return cert;
  }