Skip to content

Commit

Permalink
add endpoint for listing truststore contents filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Apr 16, 2024
1 parent 6a87d9d commit 5b64e57
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/ConfigProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ public class ConfigProperties {
public static final String STORAGE_TRANSIENT_ARCHIVES_ENABLED =
"storage.transient-archives.enabled";
public static final String STORAGE_TRANSIENT_ARCHIVES_TTL = "storage.transient-archives.ttl";

public static final String SSL_TRUSTSTORE_DIR = "ssl.truststore.dir";
}
53 changes: 53 additions & 0 deletions src/main/java/io/cryostat/security/TrustStore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright The Cryostat Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cryostat.security;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;

import io.cryostat.ConfigProperties;

import io.smallrye.common.annotation.Blocking;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;

@Path("/api/v3")
public class TrustStore {

@ConfigProperty(name = ConfigProperties.SSL_TRUSTSTORE_DIR)
java.nio.file.Path trustStoreDir;

@Inject Logger logger;

@Blocking
@GET
@Path("tls/certs")
@Produces(MediaType.APPLICATION_JSON)
public List<String> listCerts() throws IOException {
return Files.walk(trustStoreDir)
.map(java.nio.file.Path::toFile)
.filter(File::isFile)
.map(File::getPath)
.toList();
}
}
5 changes: 5 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ cryostat.http.proxy.host=${quarkus.http.host}
cryostat.http.proxy.port=${quarkus.http.port}
cryostat.http.proxy.path=/

conf-dir=/opt/cryostat.d
ssl.truststore=${conf-dir}/truststore.p12
ssl.truststore.dir=/truststore
ssl.truststore.pass-file=${conf-dir}/truststore.pass

quarkus.http.auth.proactive=false
quarkus.http.host=0.0.0.0
quarkus.http.port=8181
Expand Down

0 comments on commit 5b64e57

Please sign in to comment.