public static void assertCertificateDateNotValid( String message, X509Certificate certificate, Date date )
    {
        try
        {
            certificate.checkValidity( date );
            fail( message );
        }
        catch ( CertificateExpiredException | CertificateNotYetValidException e )
        {
            // This is expected to be thrown.
        }
    }
@see <a href="https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java>https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java</a>
xmppserver/src/test/java/org/jivesoftware/util/CertificateManagerTest.java