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

# Certificate

` public abstract class Certificate `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.security.cert.Certificate |

Known direct subclasses [X509Certificate](https://developer.android.com/reference/javax/security/cert/X509Certificate) [X509Certificate](https://developer.android.com/reference/javax/security/cert/X509Certificate) Abstract class for X.509 v1 certificates.   

*** ** * ** ***

<br />

Abstract class for managing a variety of identity certificates. An identity certificate is a guarantee by a principal that a public key is that of another principal. (A principal represents an entity such as an individual user, a group, or a corporation.)

This class is an abstraction for certificates that have different formats but important common uses. For example, different types of certificates, such as X.509 and PGP, share general certificate functionality (like encoding and verifying) and some types of information (like a public key).

X.509, PGP, and SDSI certificates can all be implemented by subclassing the Certificate class, even though they contain different sets of information, and they store and retrieve the information in different ways.

*Note: The classes in the package `javax.security.cert` exist for compatibility with earlier versions of the Java Secure Sockets Extension (JSSE). New applications should instead use the standard Java SE certificate classes located in `java.security.cert`.*

<br />

**See also:**

- `https://developer.android.com/reference/javax/security/cert/X509Certificate`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/security/cert/Certificate#Certificate()() ` |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/javax/security/cert/Certificate#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object other) ` Compares this certificate for equality with the specified object. |
| ` abstract byte[]` | ` https://developer.android.com/reference/javax/security/cert/Certificate#getEncoded()() ` Returns the encoded form of this certificate. |
| ` abstract https://developer.android.com/reference/java/security/PublicKey` | ` https://developer.android.com/reference/javax/security/cert/Certificate#getPublicKey()() ` Gets the public key from this certificate. |
| ` int` | ` https://developer.android.com/reference/javax/security/cert/Certificate#hashCode()() ` Returns a hashcode value for this certificate from its encoded form. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/security/cert/Certificate#toString()() ` Returns a string representation of this certificate. |
| ` abstract void` | ` https://developer.android.com/reference/javax/security/cert/Certificate#verify(java.security.PublicKey,%20java.lang.String)(https://developer.android.com/reference/java/security/PublicKey key, https://developer.android.com/reference/java/lang/String sigProvider) ` Verifies that this certificate was signed using the private key that corresponds to the specified public key. |
| ` abstract void` | ` https://developer.android.com/reference/javax/security/cert/Certificate#verify(java.security.PublicKey)(https://developer.android.com/reference/java/security/PublicKey key) ` Verifies that this certificate was signed using the private key that corresponds to the specified public key. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` 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 https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` 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` ` 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` ` 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

### Certificate

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

```
public Certificate ()
```

<br />

<br />

## Public methods

### equals

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

```
public boolean equals (Object other)
```

Compares this certificate for equality with the specified object. If the `other` object is an `instanceof` `Certificate`, then its encoded form is retrieved and compared with the encoded form of this certificate.

<br />

| Parameters ||
|---|---|
| `other` | `Object`: the object to test for equality with this certificate. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the encoded forms of the two certificates match, false otherwise. <br /> |

### getEncoded

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

```
public abstract byte[] getEncoded ()
```

Returns the encoded form of this certificate. It is assumed that each certificate type would have only a single form of encoding; for example, X.509 certificates would be encoded as ASN.1 DER.

<br />

| Returns ||
|---|---|
| `byte[]` | encoded form of this certificate <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/security/cert/CertificateEncodingException` | on internal certificate encoding failure |

### getPublicKey

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

```
public abstract PublicKey getPublicKey ()
```

Gets the public key from this certificate.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/PublicKey` | the public key. <br /> |

### hashCode

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

```
public int hashCode ()
```

Returns a hashcode value for this certificate from its encoded form.

<br />

| Returns ||
|---|---|
| `int` | the hashcode value. <br /> |

### toString

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

```
public abstract String toString ()
```

Returns a string representation of this certificate.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this certificate. <br /> |

### verify

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

```
public abstract void verify (PublicKey key, 
                String sigProvider)
```

Verifies that this certificate was signed using the private key that corresponds to the specified public key. This method uses the signature verification engine supplied by the specified provider.

<br />

| Parameters ||
|---|---|
| `key` | `PublicKey`: the PublicKey used to carry out the verification. <br /> |
| `sigProvider` | `String`: the name of the signature provider. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | on incorrect key. |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | on unsupported signature algorithms. |
| `https://developer.android.com/reference/java/security/NoSuchProviderException` | on incorrect provider. |
| `https://developer.android.com/reference/java/security/SignatureException` | on signature errors. |
| `https://developer.android.com/reference/javax/security/cert/CertificateException` | on encoding errors. |

### verify

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

```
public abstract void verify (PublicKey key)
```

Verifies that this certificate was signed using the private key that corresponds to the specified public key.

<br />

| Parameters ||
|---|---|
| `key` | `PublicKey`: the PublicKey used to carry out the verification. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | on incorrect key. |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | on unsupported signature algorithms. |
| `https://developer.android.com/reference/java/security/NoSuchProviderException` | if there's no default provider. |
| `https://developer.android.com/reference/java/security/SignatureException` | on signature errors. |
| `https://developer.android.com/reference/javax/security/cert/CertificateException` | on encoding errors. |