Class PemUtils


  • public final class PemUtils
    extends Object
    Reads PEM formatted private keys and certificates as identity material and trust material and maps it to either a X509ExtendedKeyManager or X509ExtendedTrustManager.

    The PemUtils provides also other methods for example to:
     - load trusted certificates and map it into a list of X509Certificate
     - load identity material and map it into a PrivateKey
     

    The PemUtils serves mainly as a helper class to easily supply the PEM formatted SSL material for the SSLFactory, but can also be used for other purposes.

    Author:
    Hakan Altindag
    • Method Detail

      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(String certificateChainPath,
                                                                  String privateKeyPath)
        Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(String certificateChainPath,
                                                                  String privateKeyPath,
                                                                  char[] keyPassword)
        Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(Path certificateChainPath,
                                                                  Path privateKeyPath)
        Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(Path certificateChainPath,
                                                                  Path privateKeyPath,
                                                                  char[] keyPassword)
        Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(String identityPath)
        Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(String identityPath,
                                                                  char[] keyPassword)
        Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(Path identityPath)
        Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(Path identityPath,
                                                                  char[] keyPassword)
        Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(InputStream identityStream)
        Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance of X509ExtendedKeyManager
      • loadIdentityMaterial

        public static X509ExtendedKeyManager loadIdentityMaterial​(InputStream identityStream,
                                                                  char[] keyPassword)
        Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance of X509ExtendedKeyManager
      • parseIdentityMaterial

        public static X509ExtendedKeyManager parseIdentityMaterial​(String identityContent)
        Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance of X509ExtendedTrustManager
      • parseIdentityMaterial

        public static X509ExtendedKeyManager parseIdentityMaterial​(String identityContent,
                                                                   char[] keyPassword)
        Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance of X509ExtendedTrustManager
      • parseIdentityMaterial

        public static X509ExtendedKeyManager parseIdentityMaterial​(String certificateChainContent,
                                                                   String privateKeyContent,
                                                                   char[] keyPassword)
        Parses the identity material based on a string representation of the certificate chain and the private key and maps it to an instance of X509ExtendedTrustManager
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(String identityPath)
        Loads the private key from the classpath and maps it to an instance of PrivateKey
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(String identityPath,
                                                char[] keyPassword)
        Loads the private key from the classpath and maps it to an instance of PrivateKey
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(Path identityPath)
        Loads the private key from the filesystem and maps it to an instance of PrivateKey
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(Path identityPath,
                                                char[] keyPassword)
        Loads the private key from the filesystem and maps it to an instance of PrivateKey
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(InputStream identityStream)
        Loads the private key from an InputStream and maps it to an instance of PrivateKey
      • loadPrivateKey

        public static PrivateKey loadPrivateKey​(InputStream identityStream,
                                                char[] keyPassword)
        Loads the private key from an InputStream and maps it to an instance of PrivateKey
      • parsePrivateKey

        public static PrivateKey parsePrivateKey​(String identityContent)
        Parses the private key based on a string representation of the private key and maps it to an instance of PrivateKey
      • parsePrivateKey

        public static PrivateKey parsePrivateKey​(String identityContent,
                                                 char[] keyPassword)
        Parses the private key based on a string representation of the private key and maps it to an instance of PrivateKey. If the identity content contains multiple private keys it will use only the first one.