# HandshakeCompletedEvent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Fields](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#inhfields)\|[Ctors](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#pubctors)\|[Methods](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#inhmethods)  

# HandshakeCompletedEvent

`
public


class
HandshakeCompletedEvent
`  
`


``

extends `[EventObject](https://developer.android.com/reference/java/util/EventObject)`


``


`

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

<br />

*** ** * ** ***

This event indicates that an SSL handshake completed on a given SSL connection. All of the core information about that handshake's result is captured through an "SSLSession" object. As a convenience, this event class provides direct access to some important session attributes.

The source of this event is the SSLSocket on which handshaking just completed.  
**See also:**

- [SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)
- [HandshakeCompletedListener](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedListener)
- [SSLSession](https://developer.android.com/reference/javax/net/ssl/SSLSession)

## Summary

|                                                                                                                                                                                                                                                              ### Inherited fields                                                                                                                                                                                                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.util.EventObject](https://developer.android.com/reference/java/util/EventObject) |---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| | ` protected `[Object](https://developer.android.com/reference/java/lang/Object) | [source](https://developer.android.com/reference/java/util/EventObject#source) The object on which the Event initially occurred. | |

|                                                                                                                                                                                              ### Public constructors                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[HandshakeCompletedEvent](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#HandshakeCompletedEvent(javax.net.ssl.SSLSocket,%20javax.net.ssl.SSLSession))`(`[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)` sock, `[SSLSession](https://developer.android.com/reference/javax/net/ssl/SSLSession)` s) ` Constructs a new HandshakeCompletedEvent. |

|                                                                                                                                                           ### Public methods                                                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[String](https://developer.android.com/reference/java/lang/String)                               | ` `[getCipherSuite](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getCipherSuite())`() ` Returns the cipher suite in use by the session which was produced by the handshake.                      |
| ` `[Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate)          | ` `[getLocalCertificates](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getLocalCertificates())`() ` Returns the certificate(s) that were sent to the peer during handshaking.                    |
| ` `[Principal](https://developer.android.com/reference/java/security/Principal)                     | ` `[getLocalPrincipal](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getLocalPrincipal())`() ` Returns the principal that was sent to the peer during handshaking.                                |
| ` `[X509Certificate[]](https://developer.android.com/reference/javax/security/cert/X509Certificate) | ` `[getPeerCertificateChain](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerCertificateChain())`() ` Returns the identity of the peer which was identified as part of defining the session. |
| ` `[Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate)          | ` `[getPeerCertificates](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerCertificates())`() ` Returns the identity of the peer which was established as part of defining the session.        |
| ` `[Principal](https://developer.android.com/reference/java/security/Principal)                     | ` `[getPeerPrincipal](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerPrincipal())`() ` Returns the identity of the peer which was established as part of defining the session.              |
| ` `[SSLSession](https://developer.android.com/reference/javax/net/ssl/SSLSession)                   | ` `[getSession](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getSession())`() ` Returns the session that triggered this event.                                                                   |
| ` `[SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket)                     | ` `[getSocket](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getSocket())`() ` Returns the socket which is the source of this event.                                                              |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.EventObject](https://developer.android.com/reference/java/util/EventObject)` ` |-----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[getSource](https://developer.android.com/reference/java/util/EventObject#getSource())`() ` The object on which the Event initially occurred.  | | ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/java/util/EventObject#toString())`() ` Returns a String representation of this EventObject. | ||
| 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 constructors

### HandshakeCompletedEvent

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

```
public HandshakeCompletedEvent (SSLSocket sock, 
                SSLSession s)
```

Constructs a new HandshakeCompletedEvent.

<br />

|                                 Parameters                                  ||
|--------|---------------------------------------------------------------------|
| `sock` | `SSLSocket`: the SSLSocket acting as the source of the event <br /> |
| `s`    | `SSLSession`: the SSLSession this event is associated with <br />   |

## Public methods

### getCipherSuite

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

```
public String getCipherSuite ()
```

Returns the cipher suite in use by the session which was produced by the handshake. (This is a convenience method for getting the ciphersuite from the SSLsession.)

<br />

|                                                                 Returns                                                                 ||
|--------------------------------------------------------------------|---------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the name of the cipher suite negotiated during this session. <br /> |

### getLocalCertificates

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

```
public Certificate[] getLocalCertificates ()
```

Returns the certificate(s) that were sent to the peer during handshaking. Note: This method is useful only when using certificate-based cipher suites. When multiple certificates are available for use in a handshake, the implementation chooses what it considers the "best" certificate chain available, and transmits that to the other side. This method allows the caller to know which certificate chain was actually used.

<br />

|                                                                                                                             Returns                                                                                                                              ||
|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate) | an ordered array of certificates, with the local certificate first followed by any certificate authorities. If no certificates were sent, then null is returned. <br /> |

**See also:**

- [getLocalPrincipal()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getLocalPrincipal())  

### getLocalPrincipal

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

```
public Principal getLocalPrincipal ()
```

Returns the principal that was sent to the peer during handshaking.

<br />

|                                                                                                                                                   Returns                                                                                                                                                    ||
|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Principal](https://developer.android.com/reference/java/security/Principal) | the principal sent to the peer. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. If no principal was sent, then null is returned. <br /> |

**See also:**

- [getLocalCertificates()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getLocalCertificates())
- [getPeerPrincipal()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerPrincipal())  

### getPeerCertificateChain

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

```
public X509Certificate[] getPeerCertificateChain ()
```

Returns the identity of the peer which was identified as part of defining the session. Note: This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException.

*Note: this method exists for compatibility with previous releases. New applications should use[getPeerCertificates()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerCertificates())instead.*

<br />

<br />

|                                                                                                                                                                                        Returns                                                                                                                                                                                        ||
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [X509Certificate[]](https://developer.android.com/reference/javax/security/cert/X509Certificate) | an ordered array of peer X.509 certificates, with the peer's own certificate first followed by any certificate authorities. (The certificates are in the original JSSE[X509Certificate](https://developer.android.com/reference/javax/security/cert/X509Certificate)format). <br /> |

|                                                                    Throws                                                                    ||
|----------------------------------------------------------------------------------------------------------------|------------------------------|
| [SSLPeerUnverifiedException](https://developer.android.com/reference/javax/net/ssl/SSLPeerUnverifiedException) | if the peer is not verified. |

**See also:**

- [getPeerPrincipal()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerPrincipal())  

### getPeerCertificates

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

```
public Certificate[] getPeerCertificates ()
```

Returns the identity of the peer which was established as part of defining the session. Note: This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException.

<br />

|                                                                                                          Returns                                                                                                          ||
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| [Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate) | an ordered array of the peer certificates, with the peer's own certificate first followed by any certificate authorities. <br /> |

|                                                                    Throws                                                                    ||
|----------------------------------------------------------------------------------------------------------------|------------------------------|
| [SSLPeerUnverifiedException](https://developer.android.com/reference/javax/net/ssl/SSLPeerUnverifiedException) | if the peer is not verified. |

**See also:**

- [getPeerPrincipal()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerPrincipal())  

### getPeerPrincipal

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

```
public Principal getPeerPrincipal ()
```

Returns the identity of the peer which was established as part of defining the session.

<br />

|                                                                                                                      Returns                                                                                                                      ||
|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Principal](https://developer.android.com/reference/java/security/Principal) | the peer's principal. Returns an X500Principal of the end-entity certiticate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. <br /> |

|                                                                            Throws                                                                            ||
|----------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [SSLPeerUnverifiedException](https://developer.android.com/reference/javax/net/ssl/SSLPeerUnverifiedException) | if the peer's identity has not been verified |

**See also:**

- [getPeerCertificates()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getPeerCertificates())
- [getLocalPrincipal()](https://developer.android.com/reference/javax/net/ssl/HandshakeCompletedEvent#getLocalPrincipal())  

### getSession

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

```
public SSLSession getSession ()
```

Returns the session that triggered this event.

<br />

|                                                         Returns                                                          ||
|--------------------------------------------------------------------------------|------------------------------------------|
| [SSLSession](https://developer.android.com/reference/javax/net/ssl/SSLSession) | the`SSLSession`for this handshake <br /> |

### getSocket

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

```
public SSLSocket getSocket ()
```

Returns the socket which is the source of this event. (This is a convenience function, to let applications write code without type casts.)

<br />

|                                                              Returns                                                              ||
|------------------------------------------------------------------------------|-----------------------------------------------------|
| [SSLSocket](https://developer.android.com/reference/javax/net/ssl/SSLSocket) | the socket on which the connection was made. <br /> |