private static KeyStore loadKeyStore(
            final String keyStoreFormat,
            final Resource keyStore,
            final String keyStorePassword)
            throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {

        requireNonNull(keyStoreFormat, "keyStoreFormat");
        requireNonNull(keyStore, "keyStore");
        final String detectedFormat = detectFormat(keyStoreFormat, keyStore.getFilename());
        final KeyStore ks = KeyStore.getInstance(detectedFormat);
        try (InputStream stream = keyStore.getInputStream()) {
            ks.load(stream, keystorePassword(keyStorePassword));
        }
        return ks;
    }
Loads the {@link KeyStore} from the given {@link Resource}.

@param keyStoreFormat The format of the keystore.
@param keyStore The resource containing the keystore.
@param keyStorePassword The password for the keystore. May be empty or null.
@return The newly created KeyStore.
@throws KeyStoreException If the keystore format isn't supported.
@throws IOException If there is an I/O or format problem with the keystore data, if a password is required but
        not given, or if the given password was incorrect. If the error is due to a wrong password, the
        {@link Throwable#getCause cause} of the {@code IOException} should be an
        {@code UnrecoverableKeyException}
@throws NoSuchAlgorithmException If the algorithm used to check the integrity of the keystore cannot be found
@throws CertificateException If any of the certificates in the keystore could not be loaded
grpc-common-spring-boot/src/main/java/net/devh/boot/grpc/common/security/KeyStoreUtils.java