Class KeyStoreUtil


  • public class KeyStoreUtil
    extends Object
    Utility functions for manipulating KeyStores.
    Author:
    Martin Mazanek
    • Constructor Detail

      • KeyStoreUtil

        public KeyStoreUtil()
    • Method Detail

      • loadKeyStore

        public static KeyStore loadKeyStore​(Supplier<Provider[]> providers,
                                            String providerName,
                                            FileInputStream is,
                                            String filename,
                                            char[] password)
                                     throws IOException,
                                            KeyStoreException
        Tries to parse a keystore based on known recognizable patterns.

        This method can parse JKS, JCEKS, PKCS12, BKS, BCFKS and UBER key stores as well as PEM files. At first the method looks for recognizable patterns of JKS, JCEKS, PKCS12 and BKS key store types and tries to parse them if found. If the pattern recognition fails, brute force is used to load the key store.

        The provider supplier is used for loading the key stores.

        Parameters:
        providers - provider supplier for loading the keystore (must not be null)
        providerName - if specified only providers with this name will be used
        is - the key store file input stream (must not be null)
        filename - the filename for prioritizing brute force checks using the file extension
        password - password of the key store. Should be the empty string for PEM files.
        Returns:
        loaded key store if recognized
        Throws:
        IOException
        KeyStoreException