@Test
    public void verifyIdentityProviderMetadataUrlWithBadSslCert() throws Exception {
        val metadataUrl = "https://expired.badssl.com/";
        val configuration = new SAML2Configuration("target/keystore.jks", "pac4j", "pac4j", metadataUrl);
        configuration.setForceKeystoreGeneration(true);
        configuration.setServiceProviderMetadataResource(new FileSystemResource("target/out.xml"));
        configuration.init();
        var metadataResolver = configuration.getIdentityProviderMetadataResolver().resolve();
        assertNull(metadataResolver);
        configuration.setSslSocketFactory(disabledSslContext().getSocketFactory());
        configuration.setHostnameVerifier((s, sslSession) -> true);
        assertThrows(TechnicalException.class, () -> configuration.getIdentityProviderMetadataResolver().resolve());
    }
This is {@link SAML2ConfigurationTests}.

@author Misagh Moayyed
pac4j-saml/src/test/java/org/pac4j/saml/config/SAML2ConfigurationTests.java