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

# Certificate

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

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

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

*** ** * ** ***

<br />

Abstract class for managing a variety of identity certificates. An identity certificate is a binding of a principal to a public key which is vouched for by 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.
**See also:**

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

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/java/security/cert/Certificate.CertificateRep` Alternate Certificate class for serialization. |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/cert/Certificate#Certificate(java.lang.String)(https://developer.android.com/reference/java/lang/String type) ` Creates a certificate of the specified type. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/java/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/java/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/java/security/cert/Certificate#getPublicKey()() ` Gets the public key from this certificate. |
| ` final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/cert/Certificate#getType()() ` Returns the type of this certificate. |
| ` int` | ` https://developer.android.com/reference/java/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/java/security/cert/Certificate#toString()() ` Returns a string representation of this certificate. |
| ` abstract void` | ` https://developer.android.com/reference/java/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. |
| ` void` | ` https://developer.android.com/reference/java/security/cert/Certificate#verify(java.security.PublicKey,%20java.security.Provider)(https://developer.android.com/reference/java/security/PublicKey key, https://developer.android.com/reference/java/security/Provider 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/java/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. |

| ### Protected methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/security/cert/Certificate#writeReplace()() ` Replace the Certificate to be serialized. |

### 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*.

## Protected constructors

### Certificate

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

```
protected Certificate (String type)
```

Creates a certificate of the specified type.

<br />

| Parameters ||
|---|---|
| `type` | `String`: the standard name of the certificate type. See the CertificateFactory section in the [Java Security Standard Algorithm Names Specification](https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#certificatefactory-types) for information about standard certificate types. <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 iff 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[]` | the encoded form of this certificate <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertificateEncodingException` | if an encoding error occurs. |

### 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 /> |

### getType

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

```
public final String getType ()
```

Returns the type of this certificate.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the type of this certificate. <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/java/security/cert/CertificateException` | on encoding errors. |

### verify

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

```
public void verify (PublicKey key, 
                Provider 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. Note that the specified Provider object does not have to be registered in the provider list.

This method was added to version 1.8 of the Java Platform Standard Edition. In order to maintain backwards compatibility with existing service providers, this method cannot be `abstract` and by default throws an `UnsupportedOperationException`.

<br />

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

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if the method is not supported |
| `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/SignatureException` | on signature errors. |
| `https://developer.android.com/reference/java/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/java/security/cert/CertificateException` | on encoding errors. |

## Protected methods

### writeReplace

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

```
protected Object writeReplace ()
```

Replace the Certificate to be serialized.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | the alternate Certificate object to be serialized <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/ObjectStreamException` | if a new object representing this Certificate could not be created |