# SSLSockets

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/net/ssl/SSLSockets#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/ssl/SSLSockets#inhmethods)  

# SSLSockets

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/net/ssl/SSLSockets "View this page in Kotlin")\|Java

`
public


class
SSLSockets
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.ssl.SSLSockets |

<br />

*** ** * ** ***

Static utility methods for accessing additional functionality of supported instances of[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket). Sockets from the platform TLS provider will be compatible with all methods in this class.

## Summary

|                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                 ||
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static byte[]`  | ` `[exportKeyingMaterial](https://developer.android.com/reference/android/net/ssl/SSLSockets#exportKeyingMaterial(javax.net.ssl.SSLSocket,%20java.lang.String,%20byte[],%20int))`(`[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)` socket, `[String](https://developer.android.com/reference/java/lang/String)` label, byte[] context, int length) ` Exports a value derived from the TLS master secret as described in RFC 5705. |
| ` static boolean` | ` `[isSupportedSocket](https://developer.android.com/reference/android/net/ssl/SSLSockets#isSupportedSocket(javax.net.ssl.SSLSocket))`(`[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)` socket) ` Returns whether the given socket can be used with the methods in this class.                                                                                                                                                    |
| ` static void`    | ` `[setUseSessionTickets](https://developer.android.com/reference/android/net/ssl/SSLSockets#setUseSessionTickets(javax.net.ssl.SSLSocket,%20boolean))`(`[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)` socket, boolean useSessionTickets) ` Enables or disables the use of session tickets.                                                                                                                                     |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### exportKeyingMaterial

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

```
public static byte[] exportKeyingMaterial (SSLSocket socket, 
                String label, 
                byte[] context, 
                int length)
```

Exports a value derived from the TLS master secret as described in RFC 5705. A number of protocols leverage Transport Layer Security (TLS) to perform key establishment but then use some of the keying material for their own purposes. This method allows an application to export keying material from a TLS connection. The exported material will be the same on the client and server if they pass in the same values for`label`and`context`. See RFC 5705 for further details.

<br />

|                                                                                                    Parameters                                                                                                     ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `socket`  | `SSLSocket`: the socket to use for exporting keying material This value cannot be`null`. <br />                                                                                                        |
| `label`   | `String`: the label to use in calculating the exported value. This must be an ASCII-only string. This value cannot be`null`. <br />                                                                    |
| `context` | `byte`: the application-specific context value to use in calculating the exported value. This may be`null`to use no application context, which is treated differently than an empty byte array. <br /> |
| `length`  | `int`: the number of bytes of keying material to return. <br />                                                                                                                                        |

|                                                               Returns                                                               ||
|----------|---------------------------------------------------------------------------------------------------------------------------|
| `byte[]` | a value of the specified length, or`null`if the handshake has not yet completed or the connection has been closed. <br /> |

|                                                         Throws                                                          ||
|------------------------------------------------------------------------------------|-------------------------------------|
| [SSLException](https://developer.android.com/reference/javax/net/ssl/SSLException) | if the value could not be exported. |

### isSupportedSocket

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

```
public static boolean isSupportedSocket (SSLSocket socket)
```

Returns whether the given socket can be used with the methods in this class. In general, only sockets from the platform TLS provider are supported.

<br />

|                        Parameters                         ||
|----------|-------------------------------------------------|
| `socket` | `SSLSocket`: This value cannot be`null`. <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### setUseSessionTickets

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

```
public static void setUseSessionTickets (SSLSocket socket, 
                boolean useSessionTickets)
```

Enables or disables the use of session tickets.

This function must be called before the handshake is started or it will have no effect.

<br />

|                                           Parameters                                           ||
|---------------------|---------------------------------------------------------------------------|
| `socket`            | `SSLSocket`: the socket This value cannot be`null`. <br />                |
| `useSessionTickets` | `boolean`: whether to enable or disable the use of session tickets <br /> |

|                                                                        Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the given socket is not a platform socket |