{"record":{"id":"576b600686ad42c4","repo":"quarkusio/quarkus","slug":"the-provided-hostname-verifier-verifier-is-not","errorCode":null,"errorMessage":"The provided hostname verifier ${verifier} is not an instance of HostnameVerifier","messagePattern":"The provided hostname verifier (.+?) is not an instance of HostnameVerifier","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java","lineNumber":166,"sourceCode":"        }\n    }\n\n    private void registerHostnameVerifier(String verifier, RestClientBuilder 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, RestClientBuilder builder) {\n        try {\n            Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n            KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse(\"JKS\"));\n\n            Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());\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":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java#L148-L184","documentation":"The class configured as hostname verifier loaded and instantiated fine, but the resulting object does not implement javax.net.ssl.HostnameVerifier, so the cast in registerHostnameVerifier failed with ClassCastException. The configured class must implement HostnameVerifier.","triggerScenarios":"Setting quarkus.rest-client.<name>.hostname-verifier to a class that implements a similarly-named but different interface, or an unrelated class entirely.","commonSituations":"Implementing the wrong HostnameVerifier (e.g. an application-specific interface of the same name); refactoring that changed the interface the class implements; copy-paste of a verifier from another library.","solutions":["Make the configured class implement javax.net.ssl.HostnameVerifier and its verify(String, SSLSession) method","Check for import mistakes — implement javax.net.ssl.HostnameVerifier, not another HostnameVerifier type","Verify the configured class name points at the intended verifier"],"exampleFix":"// before\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\npublic class MyVerifier extends NoopHostnameVerifier {}\n// after\nimport javax.net.ssl.HostnameVerifier;\npublic class MyVerifier implements HostnameVerifier {\n    public boolean verify(String host, SSLSession session) { return true; }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(verifierName);\nif (!javax.net.ssl.HostnameVerifier.class.isAssignableFrom(c)) {\n    throw new IllegalStateException(verifierName + \" does not implement javax.net.ssl.HostnameVerifier\");\n}","typeGuard":"static boolean isHostnameVerifier(Class<?> c) {\n    return javax.net.ssl.HostnameVerifier.class.isAssignableFrom(c);\n}","tryCatchPattern":"try {\n    Object o = Class.forName(verifierName).getDeclaredConstructor().newInstance();\n    if (!(o instanceof HostnameVerifier)) throw new IllegalStateException(verifierName + \" is not a HostnameVerifier\");\n    builder.hostnameVerifier((HostnameVerifier) o);\n} catch (ClassCastException e) {\n    log.error(\"Wrong HostnameVerifier interface implemented\", e);\n}","preventionTips":["Import javax.net.ssl.HostnameVerifier exactly — beware same-named interfaces from other libraries","Add an instanceof assert/unit test for every configured verifier","Check implements clauses after refactors"],"tags":["restclient","ssl","classcast"],"backgroundTag":"type-cast-failed","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"}