{"record":{"id":"e5900ee0d9b473a1","repo":"quarkusio/quarkus","slug":"the-provided-hostname-verifier-verifier-is","errorCode":null,"errorMessage":"The provided hostname verifier \" + verifier + \" is not an instance of HostnameVerifier","messagePattern":"The provided hostname verifier \" \\+ verifier \\+ \" is not an instance of HostnameVerifier","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java","lineNumber":301,"sourceCode":"        oneOf(restClientConfig.verifyHost(), configRoot.verifyHost()).ifPresent(builder::verifyHost);\n    }\n\n    private void registerHostnameVerifier(String verifier, QuarkusRestClientBuilder builder) {\n        try {\n            Class<?> verifierClass = Thread.currentThread().getContextClassLoader().loadClass(verifier);\n            builder.hostnameVerifier((HostnameVerifier) verifierClass.getDeclaredConstructor().newInstance());\n        } catch (NoSuchMethodException e) {\n            throw new RuntimeException(\n                    \"Could not find a public, no-argument constructor for the hostname verifier class \" + verifier, e);\n        } catch (ClassNotFoundException e) {\n            throw new RuntimeException(\"Could not find hostname verifier class \" + verifier, e);\n        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {\n            throw new RuntimeException(\n                    \"Failed to instantiate hostname verifier class \" + verifier\n                            + \". Make sure it has a public, no-argument constructor\",\n                    e);\n        } catch (ClassCastException e) {\n            throw new RuntimeException(\"The provided hostname verifier \" + verifier + \" is not an instance of HostnameVerifier\",\n                    e);\n        }\n    }\n\n    private void registerKeyStore(String keyStorePath, QuarkusRestClientBuilder builder) {\n        Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());\n        Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n\n        try {\n            KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse(\"JKS\"));\n            if (keyStorePassword.isEmpty()) {\n                throw new IllegalArgumentException(\"No password provided for keystore\");\n            }\n            String password = keyStorePassword.get();\n\n            try (InputStream input = locateStream(keyStorePath)) {\n                keyStore.load(input, password.toCharArray());\n            } catch (IOException | CertificateException | NoSuchAlgorithmException e) {","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java#L283-L319","documentation":"The configured class loaded and was constructed successfully, but the resulting object is not a HostnameVerifier, so the cast to HostnameVerifier threw ClassCastException, wrapped in this RuntimeException. The property is meant to point exclusively at HostnameVerifier implementations.","triggerScenarios":"Setting the hostname-verifier property to a class that implements a similar interface (e.g. a custom checker) but not jakarta/javax.net.ssl.HostnameVerifier.","commonSituations":"Pointing the property at an X509TrustManager, a Spring-style HostnameVerifier, or a similarly-named class from another library; mixing javax/jakarta or different SSL utility types; copy-paste errors in configuration.","solutions":["Implement jakarta.net.ssl.HostnameVerifier (javax.net.ssl.HostnameVerifier on older stacks) in the configured class.","Verify the property value references the intended verifier class, not another SSL type.","If wrapping a third-party verifier, create a small adapter class implementing HostnameVerifier."],"exampleFix":"// before\npublic class MyChecker { public boolean check(String h, SSLSession s) {...} } // not a HostnameVerifier\n\n// after\npublic class MyChecker implements HostnameVerifier {\n    public boolean verify(String hostname, SSLSession session) { ... }\n}","handlingStrategy":"type-guard","validationCode":"Object v = Class.forName(\"com.example.MyVerifier\").getDeclaredConstructor().newInstance();\nif (!(v instanceof javax.net.ssl.HostnameVerifier)) {\n    throw new IllegalStateException(\"Configured class is not a HostnameVerifier\");\n}","typeGuard":"boolean isHostnameVerifier(String className) {\n    try {\n        Object o = Thread.currentThread().getContextClassLoader().loadClass(className).getDeclaredConstructor().newInstance();\n        return o instanceof javax.net.ssl.HostnameVerifier;\n    } catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    // build client with configured verifier\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is not an instance of HostnameVerifier\")) {\n        builder.hostnameVerifier(new DefaultVerifier());\n    } else throw e;\n}","preventionTips":["Confirm the configured class implements javax.net.ssl.HostnameVerifier (or the jakarta equivalent used by your Quarkus version).","Do not point the property at trust managers or other SSL utilities.","Write an adapter class when wrapping third-party verifiers."],"tags":["tls","rest-client","type-mismatch","configuration"],"backgroundTag":"classcast-exception","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}