public static Date findValidPointInTime( X509Certificate... chain )
    {
        Date earliestNotAfter = null;
        Date latestNotBefore = null;

        for ( final X509Certificate certificate : chain )
        {
            if ( certificate == null ) continue; // ignore nulls.

            // Find the earliest 'notAfter'
            final Date notAfter = certificate.getNotAfter();
            if (earliestNotAfter == null || ( notAfter != null && notAfter.before( earliestNotAfter ) ) )
            {
                earliestNotAfter = notAfter;
            }

            // Find the latest 'notBefore'
            final Date notBefore = certificate.getNotBefore();
            if (latestNotBefore == null || ( notBefore != null && notBefore.after( latestNotBefore ) ) )
            {
                latestNotBefore = notBefore;
            }
        }

        if ( latestNotBefore != null && earliestNotAfter != null && latestNotBefore.before( earliestNotAfter ) )
        {
            return latestNotBefore;
        }
        else
        {
            // There's no single point in time in which all certificates in this chain are valid.
            return null;
        }
    }
Attempts to find a point in time on which each of the certificates in the chain will pass
{@link X509Certificate#checkValidity(Date)}

@param chain The chain for which to find a valid point in time (cannot be null, or empty).
@return A date on which all certificates in the chain are valid, or null of no such date is available.
xmppserver/src/main/java/org/jivesoftware/openfire/keystore/CertificateUtils.java