mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 17:18:40 +01:00
Fix NPE on null Keystore when using old .jks cert
This commit is contained in:
parent
e41af49544
commit
9737aa1ddc
@ -33,6 +33,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
@ -130,14 +131,14 @@ public class JettyWebserver implements WebServer {
|
||||
}
|
||||
|
||||
webserverLogMessages.infoWebserverEnabled(getPort());
|
||||
sslContext.ifPresent(this::logCertificateExpiryInformation);
|
||||
sslContext.map(SslContextFactory::getKeyStore).ifPresent(this::logCertificateExpiryInformation);
|
||||
|
||||
responseResolver.registerPages();
|
||||
}
|
||||
|
||||
private void logCertificateExpiryInformation(SslContextFactory.Server sslContext) {
|
||||
private void logCertificateExpiryInformation(KeyStore keyStore) {
|
||||
try {
|
||||
Certificate certificate = sslContext.getKeyStore().getCertificate(webserverConfiguration.getAlias());
|
||||
Certificate certificate = keyStore.getCertificate(webserverConfiguration.getAlias());
|
||||
if (certificate instanceof X509Certificate) {
|
||||
long expires = ((X509Certificate) certificate).getNotAfter().getTime();
|
||||
long timeLeft = expires - System.currentTimeMillis();
|
||||
|
Loading…
Reference in New Issue
Block a user