Skip to content

Commit

Permalink
Add proper WebApplicationException to the null cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarranzan committed Feb 27, 2025
1 parent ad6d760 commit 68dbb91
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import io.quarkus.tls.TlsConfiguration;
import io.quarkus.tls.TlsConfigurationRegistry;
Expand All @@ -29,11 +31,13 @@ public String tlsRegistryInspection() throws KeyStoreException, CertificateParsi

KeyStore keyStore = tlsConfiguration.getKeyStore();
if (keyStore == null) {
return "No KeyStore found in default TLS configuration.";
throw new WebApplicationException("No KeyStore found in default TLS configuration.",
Response.Status.INTERNAL_SERVER_ERROR);
}
X509Certificate x509Certificate = (X509Certificate) keyStore.getCertificate(DUMMY_ENTRY_CERT);
if (x509Certificate == null) {
return "No certificate found with alias " + DUMMY_ENTRY_CERT;
throw new WebApplicationException("No certificate found with alias " + DUMMY_ENTRY_CERT,
Response.Status.INTERNAL_SERVER_ERROR);
}
return "Subject X500 : " + x509Certificate.getSubjectX500Principal().getName()
+ "\nSubject Alternative names (SANs) : " + x509Certificate.getSubjectAlternativeNames();
Expand Down

0 comments on commit 68dbb91

Please sign in to comment.