# IkeSessionParams.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/ipsec/ike/IkeSessionParams.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                   ||
| ↳ | [android.net.ipsec.ike.IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) |

This class can be used to incrementally construct a[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams).

## Summary

|                                                                                                                                                                                                            Public constructors                                                                                                                                                                                                            ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#Builder())`()` Construct Builder                                                                                                                                                                                                                                                                                               |
| [Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#Builder(android.net.ipsec.ike.IkeSessionParams))`(`ikeSessionParams:` `[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)`)` Construct Builder from the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)object. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [addIkeOption](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#addIkeOption(kotlin.Int))`(`ikeOption:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the specified IKE Option as enabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [addIkeSaProposal](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#addIkeSaProposal(android.net.ipsec.ike.IkeSaProposal))`(`proposal:` `[IkeSaProposal](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSaProposal)`)` Adds an IKE SA proposal to the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)                  | [build](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#build())`()` Validates and builds the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [removeIkeOption](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#removeIkeOption(kotlin.Int))`(`ikeOption:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Resets (disables) the specified IKE Option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setAuthDigitalSignature](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setAuthDigitalSignature(java.security.cert.X509Certificate,%20java.security.cert.X509Certificate,%20java.security.PrivateKey))`(`serverCaCert:` `[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?`, `clientEndCert:` `[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)`, `clientPrivateKey:` `[PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#)`)` Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use public-key-signature-based authentication.                                                                                                                                                                                                                                                                                      |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setAuthDigitalSignature](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setAuthDigitalSignature(java.security.cert.X509Certificate,%20java.security.cert.X509Certificate,%20kotlin.collections.MutableList,%20java.security.PrivateKey))`(`serverCaCert:` `[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?`, `clientEndCert:` `[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)`, `clientIntermediateCerts:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)!>`, `clientPrivateKey:` `[PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#)`)` Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use public-key-signature-based authentication. |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setAuthEap](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setAuthEap(java.security.cert.X509Certificate,%20android.net.eap.EapSessionConfig))`(`serverCaCert:` `[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?`, `eapConfig:` `[EapSessionConfig](https://developer.android.com/reference/kotlin/android/net/eap/EapSessionConfig.html#)`)` Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use EAP authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setAuthPsk](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setAuthPsk(kotlin.ByteArray))`(`sharedKey:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`)` Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use pre-shared-key-based authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setDpdDelaySeconds](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setDpdDelaySeconds(kotlin.Int))`(`dpdDelaySeconds:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the Dead Peer Detection(DPD) delay in seconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setLifetimeSeconds](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setLifetimeSeconds(kotlin.Int,%20kotlin.Int))`(`hardLifetimeSeconds:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `softLifetimeSeconds:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets hard and soft lifetimes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setLocalIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setLocalIdentification(android.net.ipsec.ike.IkeIdentification))`(`identification:` `[IkeIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeIdentification)`)` Sets local IKE identification for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setNattKeepAliveDelaySeconds](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setNattKeepAliveDelaySeconds(kotlin.Int))`(`nattKeepaliveDelaySeconds:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the Network Address Translation Traversal (NATT) keepalive delay in seconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setNetwork](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setNetwork(android.net.Network))`(`network:` `[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)?`)` Sets the[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setRemoteIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setRemoteIdentification(android.net.ipsec.ike.IkeIdentification))`(`identification:` `[IkeIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeIdentification)`)` Sets remote IKE identification for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setRetransmissionTimeoutsMillis](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setRetransmissionTimeoutsMillis(kotlin.IntArray))`(`retransTimeoutMillisList:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)`)` Sets the retransmission timeout list in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | [setServerHostname](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#setServerHostname(kotlin.String))`(`serverHostname:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the server hostname for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

## Public constructors

### Builder

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

```
Builder()
```

Construct Builder  

### Builder

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

```
Builder(ikeSessionParams: IkeSessionParams)
```

Construct Builder from the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)object.

|                                                                                                 Parameters                                                                                                  ||
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ikeSessionParams` | [IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams):the object this Builder will be constructed with. This value cannot be`null`. |

## Public methods

### addIkeOption

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

```
fun addIkeOption(ikeOption: Int): IkeSessionParams.Builder
```

Sets the specified IKE Option as enabled.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||
|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ikeOption` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the option to be enabled. Value is[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_ACCEPT_ANY_REMOTE_ID](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_ACCEPT_ANY_REMOTE_ID:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_MOBIKE](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_MOBIKE:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_FORCE_PORT_4500](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_FORCE_PORT_4500:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_INITIAL_CONTACT](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_INITIAL_CONTACT:kotlin.Int), android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_REKEY_MOBILITY, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_ADDRESS_FAMILY_SELECTION, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_NATT_KEEPALIVES, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_KEEPALIVE_ON_OFF, or android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_FORCE_DNS_RESOLUTION |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

|                                Exceptions                                ||
|--------------------------------------|------------------------------------|
| `java.lang.IllegalArgumentException` | if the provided option is invalid. |

### addIkeSaProposal

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

```
fun addIkeSaProposal(proposal: IkeSaProposal): IkeSessionParams.Builder
```

Adds an IKE SA proposal to the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.

|                                                                          Parameters                                                                          ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `proposal` | [IkeSaProposal](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSaProposal):IKE SA proposal. This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### build

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

```
fun build(): IkeSessionParams
```

Validates and builds the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams).

|                                                                                         Return                                                                                          ||
|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams) | IkeSessionParams the validated IkeSessionParams. This value cannot be`null`. |

### removeIkeOption

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

```
fun removeIkeOption(ikeOption: Int): IkeSessionParams.Builder
```

Resets (disables) the specified IKE Option.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ikeOption` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the option to be disabled. Value is[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_ACCEPT_ANY_REMOTE_ID](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_ACCEPT_ANY_REMOTE_ID:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_MOBIKE](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_MOBIKE:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_FORCE_PORT_4500](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_FORCE_PORT_4500:kotlin.Int),[android.net.ipsec.ike.IkeSessionParams#IKE_OPTION_INITIAL_CONTACT](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_INITIAL_CONTACT:kotlin.Int), android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_REKEY_MOBILITY, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_ADDRESS_FAMILY_SELECTION, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_NATT_KEEPALIVES, android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_AUTOMATIC_KEEPALIVE_ON_OFF, or android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_FORCE_DNS_RESOLUTION |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

|                                Exceptions                                ||
|--------------------------------------|------------------------------------|
| `java.lang.IllegalArgumentException` | if the provided option is invalid. |

### setAuthDigitalSignature

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

```
fun setAuthDigitalSignature(
    serverCaCert: X509Certificate?, 
    clientEndCert: X509Certificate, 
    clientPrivateKey: PrivateKey
): IkeSessionParams.Builder
```

Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use public-key-signature-based authentication.

The public key included by the client end certificate and the private key used for signing MUST be a matching key pair.

The IKE library will use the strongest signature algorithm supported by both sides.

Currenly only RSA digital signature is supported.

|                                                                                                                                                                                                              Parameters                                                                                                                                                                                                              ||
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `serverCaCert`     | [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?:the CA certificate for validating the received server certificate(s). If a certificate is provided, it MUST be the root CA used by the server, or authentication will fail. If no certificate is provided, any root CA in the system's truststore is considered acceptable. This value may be`null`. |
| `clientEndCert`    | [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#):the end certificate for remote server to verify the locally generated signature. This value cannot be`null`.                                                                                                                                                                                          |
| `clientPrivateKey` | [PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#):private key to generate outbound digital signature. The[PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#)MUST be an instance of[RSAKey](https://developer.android.com/reference/kotlin/java/security/interfaces/RSAKey.html#). This value cannot be`null`.                  |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setAuthDigitalSignature

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

```
fun setAuthDigitalSignature(
    serverCaCert: X509Certificate?, 
    clientEndCert: X509Certificate, 
    clientIntermediateCerts: MutableList<X509Certificate!>, 
    clientPrivateKey: PrivateKey
): IkeSessionParams.Builder
```

Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use public-key-signature-based authentication.

The public key included by the client end certificate and the private key used for signing MUST be a matching key pair.

The IKE library will use the strongest signature algorithm supported by both sides.

Currenly only RSA digital signature is supported.

|                                                                                                                                                                                                         Parameters                                                                                                                                                                                                         ||
|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `serverCaCert`            | [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?:the CA certificate for validating the received server certificate(s). If a null value is provided, IKE library will try all default CA certificates stored in Android system to do the validation. Otherwise, it will only use the provided CA certificate.                         |
| `clientEndCert`           | [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#):the end certificate for remote server to verify locally generated signature. This value cannot be`null`.                                                                                                                                                                             |
| `clientIntermediateCerts` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)!\>:intermediate certificates for the remote server to validate the end certificate. This value cannot be`null`.                                                             |
| `clientPrivateKey`        | [PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#):private key to generate outbound digital signature. The[PrivateKey](https://developer.android.com/reference/kotlin/java/security/PrivateKey.html#)MUST be an instance of[RSAKey](https://developer.android.com/reference/kotlin/java/security/interfaces/RSAKey.html#). This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setAuthEap

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

```
fun setAuthEap(
    serverCaCert: X509Certificate?, 
    eapConfig: EapSessionConfig
): IkeSessionParams.Builder
```

Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use EAP authentication.

Not all EAP methods provide mutual authentication. As such EAP MUST be used in conjunction with a public-key-signature-based authentication of the remote server, unless EAP-Only authentication is enabled.

Callers may enable EAP-Only authentication by setting[IKE_OPTION_EAP_ONLY_AUTH](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH:kotlin.Int), which will make IKE library request the remote to use EAP-Only authentication. The remote may opt to reject the request, at which point the received certificates and authentication payload WILL be validated with the provided root CA or system's truststore as usual. Only safe EAP methods as listed in RFC 5998 will be accepted for EAP-Only authentication.

If[IKE_OPTION_EAP_ONLY_AUTH](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_OPTION_EAP_ONLY_AUTH:kotlin.Int)is set, callers MUST configure EAP as the authentication method and all EAP methods set in EAP Session configuration MUST be safe methods that are accepted for EAP-Only authentication. Otherwise callers will get an exception when building the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)

Callers MUST declare only one authentication method. Calling this function will override the previously set authentication configuration.

|                                                                                                                                                                                                            Parameters                                                                                                                                                                                                            ||
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `serverCaCert` | [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html#)?:the CA certificate for validating the received server certificate(s). If a certificate is provided, it MUST be the root CA used by the server, or authentication will fail. If no certificate is provided, any root CA in the system's truststore is considered acceptable. This value may be`null`. |
| `eapConfig`    | [EapSessionConfig](https://developer.android.com/reference/kotlin/android/net/eap/EapSessionConfig.html#):This value cannot be`null`.                                                                                                                                                                                                                                                                            |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

**See Also**

### setAuthPsk

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

```
fun setAuthPsk(sharedKey: ByteArray): IkeSessionParams.Builder
```

Configures the[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession)to use pre-shared-key-based authentication.

Both client and server MUST be authenticated using the provided shared key. IKE authentication will fail if the remote peer tries to use other authentication methods.

Callers MUST declare only one authentication method. Calling this function will override the previously set authentication configuration.

Callers SHOULD NOT use this if any other authentication methods can be used; PSK-based authentication is generally considered insecure.

|                                                                    Parameters                                                                    ||
|-------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `sharedKey` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html):the shared key. This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setDpdDelaySeconds

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

```
fun setDpdDelaySeconds(dpdDelaySeconds: Int): IkeSessionParams.Builder
```

Sets the Dead Peer Detection(DPD) delay in seconds.

|                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                  ||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dpdDelaySeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):number of seconds after which IKE SA will initiate DPD if no inbound cryptographically protected IKE message was received. Defaults to 120 seconds. MUST be a value greater than or equal to than 20 seconds. Setting the value to[IkeSessionParams.IKE_DPD_DELAY_SEC_DISABLED](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams#IKE_DPD_DELAY_SEC_DISABLED:kotlin.Int)will disable DPD. Value is android.net.ipsec.ike.IkeSessionParams#IKE_DPD_DELAY_SEC_MIN or greater |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setLifetimeSeconds

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

```
fun setLifetimeSeconds(
    hardLifetimeSeconds: Int, 
    softLifetimeSeconds: Int
): IkeSessionParams.Builder
```

Sets hard and soft lifetimes.

Lifetimes will not be negotiated with the remote IKE server.

|                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                      ||
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `hardLifetimeSeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):number of seconds after which IKE SA will expire. Defaults to 14400 seconds (4 hours). MUST be a value from 300 seconds (5 minutes) to 86400 seconds (24 hours), inclusive. Value is between android.net.ipsec.ike.IkeSessionParams#IKE_HARD_LIFETIME_SEC_MINIMUM and android.net.ipsec.ike.IkeSessionParams#IKE_HARD_LIFETIME_SEC_MAXIMUM inclusive                               |
| `softLifetimeSeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):number of seconds after which IKE SA will request rekey. Defaults to 7200 seconds (2 hours). MUST be at least 120 seconds (2 minutes), and at least 60 seconds (1 minute) shorter than the hard lifetime. Value is between android.net.ipsec.ike.IkeSessionParams#IKE_SOFT_LIFETIME_SEC_MINIMUM and android.net.ipsec.ike.IkeSessionParams#IKE_HARD_LIFETIME_SEC_MAXIMUM inclusive |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setLocalIdentification

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

```
fun setLocalIdentification(identification: IkeIdentification): IkeSessionParams.Builder
```

Sets local IKE identification for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.

It is not allowed to use KEY ID together with digital-signature-based authentication as per RFC 7296.

|                                                                                       Parameters                                                                                        ||
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `identification` | [IkeIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeIdentification):the local IKE identification. This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setNattKeepAliveDelaySeconds

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

```
fun setNattKeepAliveDelaySeconds(nattKeepaliveDelaySeconds: Int): IkeSessionParams.Builder
```

Sets the Network Address Translation Traversal (NATT) keepalive delay in seconds.

|                                                                                                                                                                                                              Parameters                                                                                                                                                                                                              ||
|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `nattKeepaliveDelaySeconds` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):number of seconds between keepalive packet transmissions. Defaults to 10 seconds. MUST be a value from 10 seconds to 3600 seconds, inclusive. Value is between android.net.ipsec.ike.IkeSessionParams#IKE_NATT_KEEPALIVE_DELAY_SEC_MIN and android.net.ipsec.ike.IkeSessionParams#IKE_NATT_KEEPALIVE_DELAY_SEC_MAX inclusive |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setNetwork

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

```
fun setNetwork(network: Network?): IkeSessionParams.Builder
```

Sets the[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.

If no[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)is provided, the default Network (as per[android.net.ConnectivityManager#getActiveNetwork()](https://developer.android.com/reference/kotlin/android/net/ConnectivityManager.html#getActiveNetwork())) will be used when constructing an[IkeSession](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSession).

|                                                                                                                                                               Parameters                                                                                                                                                                ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `network` | [Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)?:the[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#)that IKE Session will use, or`null`to clear the previously set[Network](https://developer.android.com/reference/kotlin/android/net/Network.html#) |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setRemoteIdentification

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

```
fun setRemoteIdentification(identification: IkeIdentification): IkeSessionParams.Builder
```

Sets remote IKE identification for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.

|                                                                                        Parameters                                                                                        ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `identification` | [IkeIdentification](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeIdentification):the remote IKE identification. This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setRetransmissionTimeoutsMillis

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

```
fun setRetransmissionTimeoutsMillis(retransTimeoutMillisList: IntArray): IkeSessionParams.Builder
```

Sets the retransmission timeout list in milliseconds.

Configures the retransmission by providing an array of relative retransmission timeouts in milliseconds. After sending out a request and before receiving the response, the IKE Session will iterate through the array and wait for the relative timeout before the next retry. If the last timeout is exceeded, the IKE Session will be terminated.

Each element in the array MUST be a value from 500 ms to 1800000 ms (30 minutes). The length of the array MUST NOT exceed 10. This retransmission timeout list defaults to {0.5s, 1s, 2s, 4s, 8s}

|                                                                                                 Parameters                                                                                                  ||
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `retransTimeoutMillisList` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html):the array of relative retransmission timeout in milliseconds. This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |

### setServerHostname

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

```
fun setServerHostname(serverHostname: String): IkeSessionParams.Builder
```

Sets the server hostname for the[IkeSessionParams](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams)being built.

|                                                                                        Parameters                                                                                         ||
|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `serverHostname` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the hostname of the IKE server, such as "ike.android.com". This value cannot be`null`. |

|                                                                                            Return                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [IkeSessionParams.Builder](https://developer.android.com/reference/kotlin/android/net/ipsec/ike/IkeSessionParams.Builder#) | Builder this, to facilitate chaining. This value cannot be`null`. |