Class PEMHelper

java.lang.Object
com.peterphi.std.crypto.PEMHelper

public class PEMHelper extends Object
PEM handling utilities
  • Method Details

    • loadCertificates

      public static KeyStore loadCertificates(File pemFile)
      Load one or more X.509 Certificates from a PEM file
      Parameters:
      pemFile - A PKCS8 PEM file containing only CERTIFICATE / X.509 CERTIFICATE blocks
      Returns:
      a JKS KeyStore with the certificate aliases "certindex" where index is the 0-based index of the certificate in the PEM
      Throws:
      RuntimeException - if a problem occurs
    • parse

      public static Object parse(org.bouncycastle.util.io.pem.PemObject obj) throws GeneralSecurityException
      Parse a PemObject. Currently only supports CERTIFICATE / X.509 CERTIFICATE types
      Parameters:
      obj - a PemObject with a type and with contents
      Returns:
      a parsed object (or null if the input is null)
      Throws:
      GeneralSecurityException - if there is a parsing problem
      IllegalArgumentException - if the PemObject cannot be recognised