@Override
    public JavaKeyStore load(SecureConfig config) {
        if (!exists(config)) {
            throw new SecretStoreException.LoadException(
                    String.format("Can not find Logstash keystore at %s. Please verify this file exists and is a valid Logstash keystore.",
                            config.getPlainText("keystore.file") == null ? "<undefined>" : new String(config.getPlainText("keystore.file"))));
        }
        try {
            init(config);
            lock.lock();
            try (final InputStream is = Files.newInputStream(keyStorePath)) {
                try {
                    keyStore.load(is, this.keyStorePass);
                } catch (IOException ioe) {
                    if (ioe.getCause() instanceof UnrecoverableKeyException) {
                        throw new SecretStoreException.AccessException(
                                String.format("Can not access Logstash keystore at %s. Please verify correct file permissions and keystore password.",
                                        keyStorePath.toAbsolutePath()), ioe);
                    } else {
                        throw new SecretStoreException.LoadException(String.format("Found a file at %s, but it is not a valid Logstash keystore.",
                                keyStorePath.toAbsolutePath().toString()), ioe);
                    }
                }
                byte[] marker = retrieveSecret(LOGSTASH_MARKER);
                if (marker == null) {
                    throw new SecretStoreException.LoadException(String.format("Found a keystore at %s, but it is not a Logstash keystore.",
                            keyStorePath.toAbsolutePath().toString()));
                }
                LOGGER.debug("Using existing keystore at {}", keyStorePath.toAbsolutePath());
                return this;
            }
        } catch (SecretStoreException sse) {
            throw sse;
        } catch (Exception e) { //should never happen
            throw new SecretStoreException.UnknownException("Error while trying to load the Logstash keystore", e);
        } finally {
            releaseLock(lock);
            config.clearValues();
        }
    }
@Test
    public void notLogstashKeystoreNoMarker() throws Exception {
        withDefinedPassConfig.add("keystore.file", Paths.get(this.getClass().getClassLoader().getResource("not.a.logstash.keystore").toURI()).toString().toCharArray().clone());

        assertThrows(SecretStoreException.LoadException.class, () -> {
            new JavaKeyStore().load(withDefinedPassConfig);
        });
    }