Stay organized with collections
Save and categorize content based on your preferences.
HostnameVerifier
public
interface
HostnameVerifier
javax.net.ssl.HostnameVerifier
|
Known indirect subclasses
|
This class is the base interface for hostname verification.
During handshaking, the
verification mechanism can call back to implementers of this
interface to determine if this connection should be allowed.
For more information of the use of this interface on Android, see
HttpsURLConnection.setDefaultHostnameVerifier(HostnameVerifier)
.
The policies can be certificate-based
or may depend on other authentication schemes.
Summary
Public methods |
abstract
boolean
|
verify(String hostname, SSLSession session)
Verify that the host name is an acceptable match with
the server's authentication scheme.
|
Public methods
verify
public abstract boolean verify (String hostname,
SSLSession session)
Verify that the host name is an acceptable match with
the server's authentication scheme.
Parameters |
hostname |
String : the host name |
session |
SSLSession : SSLSession used on the connection to host |
Returns |
boolean |
true if the host name is acceptable |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# HostnameVerifier\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nHostnameVerifier\n================\n\n\n`\npublic\n\n\ninterface\nHostnameVerifier\n`\n\n\n`\n\n\n`\n\n|--------------------------------|\n| javax.net.ssl.HostnameVerifier |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [AbstractVerifier](/reference/org/apache/http/conn/ssl/AbstractVerifier), [AllowAllHostnameVerifier](/reference/org/apache/http/conn/ssl/AllowAllHostnameVerifier), [BrowserCompatHostnameVerifier](/reference/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier), [StrictHostnameVerifier](/reference/org/apache/http/conn/ssl/StrictHostnameVerifier), [X509HostnameVerifier](/reference/org/apache/http/conn/ssl/X509HostnameVerifier) |----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AbstractVerifier](/reference/org/apache/http/conn/ssl/AbstractVerifier) | *This class was deprecated in API level 22. Please use [URL.openConnection()](/reference/java/net/URL#openConnection()) instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | | [AllowAllHostnameVerifier](/reference/org/apache/http/conn/ssl/AllowAllHostnameVerifier) | *This class was deprecated in API level 22. Please use [URL.openConnection()](/reference/java/net/URL#openConnection()) instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | | [BrowserCompatHostnameVerifier](/reference/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier) | *This class was deprecated in API level 22. Please use [URL.openConnection()](/reference/java/net/URL#openConnection()) instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | | [StrictHostnameVerifier](/reference/org/apache/http/conn/ssl/StrictHostnameVerifier) | *This class was deprecated in API level 22. Please use [URL.openConnection()](/reference/java/net/URL#openConnection()) instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | | [X509HostnameVerifier](/reference/org/apache/http/conn/ssl/X509HostnameVerifier) | *This interface was deprecated in API level 22. Please use [URL.openConnection()](/reference/java/net/URL#openConnection()) instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis class is the base interface for hostname verification.\n\n\nDuring handshaking, the\nverification mechanism can call back to implementers of this\ninterface to determine if this connection should be allowed.\n\n\nFor more information of the use of this interface on Android, see\n[HttpsURLConnection.setDefaultHostnameVerifier(HostnameVerifier)](/reference/javax/net/ssl/HttpsURLConnection#setDefaultHostnameVerifier(javax.net.ssl.HostnameVerifier)).\n\n\nThe policies can be certificate-based\nor may depend on other authentication schemes.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[verify](/reference/javax/net/ssl/HostnameVerifier#verify(java.lang.String,%20javax.net.ssl.SSLSession))`(`[String](/reference/java/lang/String)` hostname, `[SSLSession](/reference/javax/net/ssl/SSLSession)` session) ` Verify that the host name is an acceptable match with the server's authentication scheme. |\n\nPublic methods\n--------------\n\n### verify\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean verify (String hostname, \n SSLSession session)\n```\n\nVerify that the host name is an acceptable match with\nthe server's authentication scheme.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|----------------------------------------------------------------|\n| `hostname` | `String`: the host name \u003cbr /\u003e |\n| `session` | `SSLSession`: SSLSession used on the connection to host \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------|\n| `boolean` | true if the host name is acceptable \u003cbr /\u003e |"]]