> Documentation index: https://developer.android.com/reference/llms.txt

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#ApiLevels)  
Also in [C Extensions 22](https://developer.android.com/sdkExtensions)

# EchConfigMismatchException

*** ** * ** ***

```
open class EchConfigMismatchException : SSLException
```

|---|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) |||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.md.txt#) ||||
|   |   | ↳ | [java.io.IOException](https://developer.android.com/reference/kotlin/java/io/IOException.md.txt#) |||
|   |   |   | ↳ | [javax.net.ssl.SSLException](https://developer.android.com/reference/kotlin/javax/net/ssl/SSLException.md.txt#) ||
|   |   |   |   | ↳ | [android.net.ssl.EchConfigMismatchException](https://developer.android.com/reference/kotlin/android/net/ssl/EchConfigMismatchException.md.txt#) |

Exception thrown when the provided ECH (Encrypted Client Hello) config does not match the server.

Before accessing the retry configuration, clients **must** verify that the server's certificate is valid for the hostname returned by `getPublicHostname()`. If the returned hostname is `null`, any provided retry configuration must be ignored. Whether the client has to perform this check itself depends on how the connection was configured:

- If HTTPS endpoint identification was enabled, by calling `javax.net.ssl.SSLParameters.setEndpointIdentificationAlgorithm(String)` with `"HTTPS"`, and the platform's default `javax.net.ssl.TrustManager` is used, the certificate has already been verified against `getPublicHostname()` during the handshake, so no further hostname check is needed. If the certificate is not valid for the public hostname, this exception is not thrown; the handshake instead fails with an `javax.net.ssl.SSLHandshakeException` whose cause is a `java.security.cert.CertificateException`.
- Otherwise, clients must check the hostname themselves, for example by passing `getPublicHostname()` and the connection's `javax.net.ssl.SSLSession` to their preferred `javax.net.ssl.HostnameVerifier`.

Clients can then attempt to establish a new connection, using the provided retry `EchConfigList`, if available. A retry `EchConfigList` may not be available if the server has not provided any.

## Summary

| Public constructors ||
|---|---|
| `EchConfigMismatchException(message: String?, publicName: String?, echRetryConfigList: EchConfigList?)` Constructs a new `EchConfigMismatchException`. |

| Public methods ||
|---|---|
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | `getPublicHostname()` Returns the hostname that should be used for verification. |
| open [EchConfigList](https://developer.android.com/reference/kotlin/android/net/ssl/EchConfigList.md.txt)? | `getRetryConfigList()` Returns the `EchConfigList` provided by the server for retrying the connection, or `null` if no retry configuration was set by the server. |
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `hasRetryConfigList()` Returns `true` if a retry `EchConfigList` is available, false otherwise. |

## Public constructors

### EchConfigMismatchException

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#ApiLevels)  
Also in [C Extensions 22](https://developer.android.com/sdkExtensions)

```
EchConfigMismatchException(
    message: String?, 
    publicName: String?, 
    echRetryConfigList: EchConfigList?)
```

Constructs a new `EchConfigMismatchException`.

| Parameters ||
|---|---|
| `message` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: the detail message. This value may be `null`. |
| `publicName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: the hostname that must be used for verification, or `null` if the server did not provide a valid public name. |
| `echRetryConfigList` | [EchConfigList](https://developer.android.com/reference/kotlin/android/net/ssl/EchConfigList.md.txt)?: the `EchConfigList` provided by the server for retrying the connection, or `null` if no retry configuration was set by the server. |

## Public methods

### getPublicHostname

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#ApiLevels)  
Also in [C Extensions 22](https://developer.android.com/sdkExtensions)

```
open fun getPublicHostname(): String?
```

Returns the hostname that should be used for verification. This method must be called before interpreting the retry config list, returned by `getRetryConfigList()`. For more details see section 6.1.7 "Authenticating for the Public Name" in RFC TLS Encrypted Client Hello (draft-ietf-tls-esni-25).

| Return ||
|---|---|
| `String?` | This value may be `null`. |

### getRetryConfigList

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#ApiLevels)  
Also in [C Extensions 22](https://developer.android.com/sdkExtensions)

```
open fun getRetryConfigList(): EchConfigList?
```

Returns the `EchConfigList` provided by the server for retrying the connection, or `null` if no retry configuration was set by the server. Prior to reading this value, the client **must** verify that the certificate is valid for the name returned by `getPublicHostname()`, unless that check was already performed during the handshake by HTTPS endpoint identification (see the class documentation).

### hasRetryConfigList

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#ApiLevels)  
Also in [C Extensions 22](https://developer.android.com/sdkExtensions)

```
open fun hasRetryConfigList(): Boolean
```

Returns `true` if a retry `EchConfigList` is available, false otherwise.