Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
22](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#inhmethods)

# X509HostnameVerifier


`
public


interface
X509HostnameVerifier
`


`


implements

https://developer.android.com/reference/javax/net/ssl/HostnameVerifier


`

|---|
| org.apache.http.conn.ssl.X509HostnameVerifier |

|---|
| Known indirect subclasses [AbstractVerifier](https://developer.android.com/reference/org/apache/http/conn/ssl/AbstractVerifier), [AllowAllHostnameVerifier](https://developer.android.com/reference/org/apache/http/conn/ssl/AllowAllHostnameVerifier), [BrowserCompatHostnameVerifier](https://developer.android.com/reference/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier), [StrictHostnameVerifier](https://developer.android.com/reference/org/apache/http/conn/ssl/StrictHostnameVerifier) |---|---| | [AbstractVerifier](https://developer.android.com/reference/org/apache/http/conn/ssl/AbstractVerifier) | *This class was deprecated in API level 22. Please use `https://developer.android.com/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](https://developer.android.com/reference/org/apache/http/conn/ssl/AllowAllHostnameVerifier) | *This class was deprecated in API level 22. Please use `https://developer.android.com/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](https://developer.android.com/reference/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier) | *This class was deprecated in API level 22. Please use `https://developer.android.com/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](https://developer.android.com/reference/org/apache/http/conn/ssl/StrictHostnameVerifier) | *This class was deprecated in API level 22. Please use `https://developer.android.com/reference/java/net/URL#openConnection()` instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.* | |

<br />

*** ** * ** ***


**This interface was deprecated
in API level 22.**   

Please use `https://developer.android.com/reference/java/net/URL#openConnection()` instead.
Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html)
for further details.

Interface for checking if a hostname matches the names stored inside the
server's X.509 certificate. Implements javax.net.ssl.HostnameVerifier, but
we don't actually use that interface. Instead we added some methods that
take String parameters (instead of javax.net.ssl.HostnameVerifier's
SSLSession). JUnit is a lot easier this way! :-)

<br />

We provide the HostnameVerifier.DEFAULT, HostnameVerifier.STRICT, and HostnameVerifier.ALLOW_ALL implementations. But feel free to define your own implementation!

<br />

Inspired by Sebastian Hauer's original StrictSSLProtocolSocketFactory in the HttpClient "contrib" repository.

<br />

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#verify(java.lang.String,%20javax.net.ssl.SSLSocket)(https://developer.android.com/reference/java/lang/String host, https://developer.android.com/reference/javax/net/ssl/SSLSocket ssl) ` |
| ` abstract void` | ` https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#verify(java.lang.String,%20java.security.cert.X509Certificate)(https://developer.android.com/reference/java/lang/String host, https://developer.android.com/reference/java/security/cert/X509Certificate cert) ` |
| ` abstract void` | ` https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#verify(java.lang.String,%20java.lang.String[],%20java.lang.String[])(https://developer.android.com/reference/java/lang/String host, https://developer.android.com/reference/java/lang/String cns, https://developer.android.com/reference/java/lang/String subjectAlts) ` Checks to see if the supplied hostname matches any of the supplied CNs or "DNS" Subject-Alts. |
| ` abstract boolean` | ` https://developer.android.com/reference/org/apache/http/conn/ssl/X509HostnameVerifier#verify(java.lang.String,%20javax.net.ssl.SSLSession)(https://developer.android.com/reference/java/lang/String host, https://developer.android.com/reference/javax/net/ssl/SSLSession session) ` Verify that the host name is an acceptable match with the server's authentication scheme. |

| ### Inherited methods |
|---|---|
| From interface ` https://developer.android.com/reference/javax/net/ssl/HostnameVerifier ` |---|---| | ` abstract boolean` | ` https://developer.android.com/reference/javax/net/ssl/HostnameVerifier#verify(java.lang.String,%20javax.net.ssl.SSLSession)(https://developer.android.com/reference/java/lang/String hostname, https://developer.android.com/reference/javax/net/ssl/SSLSession session) ` Verify that the host name is an acceptable match with the server's authentication scheme. | ||

## Public methods

### verify

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void verify (String host, 
                SSLSocket ssl)
```

<br />

<br />

| Parameters ||
|---|---|
| `host` | `String` <br /> |
| `ssl` | `SSLSocket` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### verify

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void verify (String host, 
                X509Certificate cert)
```

<br />

<br />

| Parameters ||
|---|---|
| `host` | `String` <br /> |
| `cert` | `X509Certificate` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/net/ssl/SSLException` |   |

### verify

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void verify (String host, 
                String[] cns, 
                String[] subjectAlts)
```

Checks to see if the supplied hostname matches any of the supplied CNs
or "DNS" Subject-Alts. Most implementations only look at the first CN,
and ignore any additional CNs. Most implementations do look at all of
the "DNS" Subject-Alts. The CNs or Subject-Alts may contain wildcards
according to RFC 2818.

<br />

| Parameters ||
|---|---|
| `host` | `String`: The hostname to verify. <br /> |
| `cns` | `String`: CN fields, in order, as extracted from the X.509 certificate. <br /> |
| `subjectAlts` | `String`: Subject-Alt fields of type 2 ("DNS"), as extracted from the X.509 certificate. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/net/ssl/SSLException` | If verification failed. |

### verify

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean verify (String host, 
                SSLSession session)
```

Verify that the host name is an acceptable match with
the server's authentication scheme.

<br />

| Parameters ||
|---|---|
| `host` | `String`: the host name <br /> |
| `session` | `SSLSession`: SSLSession used on the connection to host <br /> |

| Returns ||
|---|---|
| `boolean` | true if the host name is acceptable <br /> |