Java KeyStore certs validity (jks)

How can i check validity of certificates from jks (java keystore).

Is there a tool to extract these certificates into PEM or DER form?

Then we could extend our SSL certificates extension.

Thanks for the quick reply.

It is possible to export jks to pem.

Can the ssl-certificate plugin check one pem file that contains many certificates and return an alert only about the one that is expiring?
Or maybe I have to make one certificate for one pem file?

es evtl etwas umständlich, aber ich hab mir da was gebaut und als lokales Plugin laufen lassen:

#!/bin/bash

########################################################
#
#       Check certificates inside a java keystore
#
########################################################
KEYTOOL="/usr/javaPATH/bin/keytool"
KEYSTORE="PATHzumZertstore/wlserver/server/lib/cacerts"
PASSWORD="changeit"
ZERT="ALIAS"    
CURRENT=`/usr/bin/date +%s`
WARNING='60'
CRITICAL='30'
$KEYTOOL -list -v -keystore $KEYSTORE  -storepass $PASSWORD 2>&1 > /dev/null
  if [ $? -gt 0 ]; then echo "Error opening the keystore."; exit 1; fi
awk '{print $2}' | while read ZERTNAME
"$ZERT" | awk '{print $3}'`
ZERTNAME=`$KEYTOOL -list -v -keystore $KEYSTORE -storepass $PASSWORD | grep "$ZERT" | awk '{print $2}'`
for ZN in $ZERTNAME
  do
 $ZN | grep "Valid from"`
   EXPIRACY=`$KEYTOOL -list -v -keystore $KEYSTORE  -storepass $PASSWORD -alias $ZN | grep "Gültig von"`
   UNTIL=`$KEYTOOL -list -v -keystore $KEYSTORE -storepass $PASSWORD -alias $ZN | grep "Gültig von" | cut -d ":" -f5-20`
   #UNTIL=`$KEYTOOL -list -v -keystore $KEYSTORE -storepass $PASSWORD -alias $ZN | grep "Valid from" | cut -d ":" -f5-20`
   UNTIL_SECONDS=`/usr/gnu/bin/date -d "$UNTIL" +%s`
   REMAINING_DAYS=$(( ($UNTIL_SECONDS -  $(/usr/gnu/bin/date +%s)) / 60 / 60 / 24 ))
   if [[ $REMAINING_DAYS -gt $WARNING ]]
    then
      echo "0 Certificate_$ZN  days=$REMAINING_DAYS Zertifikat $ZN ist noch $REMAINING_DAYS Tage gültig | $EXPIRACY "
    else
      if [[  $REMAINING_DAYS -le $CRITICAL ]]
       then
        echo "2 Certificate_$ZN  days=$REMAINING_DAYS Zertifikat $ZN ist noch $REMAINING_DAYS Tage gültig  | $EXPIRACY"
       else
        echo "1 Certificate_$ZN  days=$REMAINING_DAYS Zertifikat $ZN ist noch $REMAINING_DAYS Tage gültig  | $EXPIRACY"
      fi
   fi
  done
exit

Gruß
Sven

Thank you very much, I will test it in a few days and let you know

So you need a custom path to keytool and a password to access the keystore?

Makes it a little bit complicated.

Is there a keytool available in $PATH?

Is the password always needed?

Der benutzerdefinierten Path für keytool und Zert-Store hängt im konkreten Fall mit der Anwendungsbedingenfür die Java-Installation in unserer Umgebung zusammen, die könnte man sicherlich über entsprechende Umgebungsvariablen abfangen.
Ohne das Password kann der Zert-Store nicht abgefragt werden. Es ist allerdings das default-PW.
Gruß
Sven

not working
i use this one