Skip to content

Commit c6d3698

Browse files
committed
improved client certificate checks
1 parent 37c0282 commit c6d3698

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

dsf-common/dsf-common-jetty/src/main/java/dev/dsf/common/auth/ClientCertificateAuthenticator.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.security.NoSuchAlgorithmException;
2121
import java.security.cert.CertificateException;
2222
import java.security.cert.X509Certificate;
23+
import java.time.ZoneOffset;
24+
import java.time.ZonedDateTime;
2325
import java.util.Objects;
2426
import java.util.stream.Collectors;
2527

@@ -67,13 +69,21 @@ public AuthenticationState validateRequest(Request request, Response response, C
6769

6870
if (certificates == null || certificates.length <= 0)
6971
{
70-
logger.warn("X509Certificate could not be retrieved, sending unauthorized");
72+
logger.warn(
73+
"Client certificate could not be retrieved from jakarta request attribute, sending unauthorized");
74+
return null;
75+
}
76+
77+
if (ZonedDateTime.now()
78+
.isAfter(ZonedDateTime.ofInstant(certificates[0].getNotAfter().toInstant(), ZoneOffset.UTC)))
79+
{
80+
logger.warn("Client certificates expired, sending unauthorized");
7181
return null;
7282
}
7383

7484
try
7585
{
76-
x509TrustManager.checkClientTrusted(certificates, "RSA");
86+
x509TrustManager.checkClientTrusted(certificates, "UNKNOWN");
7787
}
7888
catch (CertificateException e)
7989
{

0 commit comments

Comments
 (0)