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

# CertStore

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

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

<br />

*** ** * ** ***

A class for retrieving `Certificate`s and `CRL`s from a repository.

This class uses a provider-based architecture. To create a `CertStore`, call one of the static `getInstance` methods, passing in the type of `CertStore` desired, any applicable initialization parameters and optionally the name of the provider desired.

Once the `CertStore` has been created, it can be used to retrieve `Certificate`s and `CRL`s by calling its `https://developer.android.com/reference/java/security/cert/CertStore#getCertificates(java.security.cert.CertSelector)` and `https://developer.android.com/reference/java/security/cert/CertStore#getCRLs(java.security.cert.CRLSelector)` methods.

Unlike a `https://developer.android.com/reference/java/security/KeyStore`, which provides access to a cache of private keys and trusted certificates, a `CertStore` is designed to provide access to a potentially vast repository of untrusted certificates and CRLs. For example, an LDAP implementation of `CertStore` provides access to certificates and CRLs stored in one or more directories using the LDAP protocol and the schema as defined in the RFC service attribute.

Every implementation of the Java platform is required to support the following standard `CertStore` type:

- `Collection`

This type is described in the [CertStore section](https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#certstore-types) of the Java Security Standard Algorithm Names Specification. Consult the release documentation for your implementation to see if any other types are supported.

**Concurrent Access**

All public methods of `CertStore` objects must be thread-safe. That is, multiple threads may concurrently invoke these methods on a single `CertStore` object (or more than one) with no ill effects. This allows a `CertPathBuilder` to search for a CRL while simultaneously searching for further certificates, for instance.

The static methods of this class are also guaranteed to be thread-safe. Multiple threads may concurrently invoke the static methods defined in this class with no ill effects.

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/cert/CertStore#CertStore(java.security.cert.CertStoreSpi,%20java.security.Provider,%20java.lang.String,%20java.security.cert.CertStoreParameters)(https://developer.android.com/reference/java/security/cert/CertStoreSpi storeSpi, https://developer.android.com/reference/java/security/Provider provider, https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/java/security/cert/CertStoreParameters params) ` Creates a `CertStore` object of the given type, and encapsulates the given provider implementation (SPI object) in it. |

| ### Public methods ||
|---|---|
| ` final https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/security/cert/CRL>` | ` https://developer.android.com/reference/java/security/cert/CertStore#getCRLs(java.security.cert.CRLSelector)(https://developer.android.com/reference/java/security/cert/CRLSelector selector) ` Returns a `Collection` of `CRL`s that match the specified selector. |
| ` final https://developer.android.com/reference/java/security/cert/CertStoreParameters` | ` https://developer.android.com/reference/java/security/cert/CertStore#getCertStoreParameters()() ` Returns the parameters used to initialize this `CertStore`. |
| ` final https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/security/cert/Certificate>` | ` https://developer.android.com/reference/java/security/cert/CertStore#getCertificates(java.security.cert.CertSelector)(https://developer.android.com/reference/java/security/cert/CertSelector selector) ` Returns a `Collection` of `Certificate`s that match the specified selector. |
| ` static final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/cert/CertStore#getDefaultType()() ` Returns the default `CertStore` type as specified by the `certstore.type` security property, or the string "LDAP" if no such property exists. |
| ` static https://developer.android.com/reference/java/security/cert/CertStore` | ` https://developer.android.com/reference/java/security/cert/CertStore#getInstance(java.lang.String,%20java.security.cert.CertStoreParameters)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/java/security/cert/CertStoreParameters params) ` Returns a `CertStore` object that implements the specified `CertStore` type and is initialized with the specified parameters. |
| ` static https://developer.android.com/reference/java/security/cert/CertStore` | ` https://developer.android.com/reference/java/security/cert/CertStore#getInstance(java.lang.String,%20java.security.cert.CertStoreParameters,%20java.security.Provider)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/java/security/cert/CertStoreParameters params, https://developer.android.com/reference/java/security/Provider provider) ` Returns a `CertStore` object that implements the specified `CertStore` type. |
| ` static https://developer.android.com/reference/java/security/cert/CertStore` | ` https://developer.android.com/reference/java/security/cert/CertStore#getInstance(java.lang.String,%20java.security.cert.CertStoreParameters,%20java.lang.String)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/java/security/cert/CertStoreParameters params, https://developer.android.com/reference/java/lang/String provider) ` Returns a `CertStore` object that implements the specified `CertStore` type. |
| ` final https://developer.android.com/reference/java/security/Provider` | ` https://developer.android.com/reference/java/security/cert/CertStore#getProvider()() ` Returns the provider of this `CertStore`. |
| ` final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/cert/CertStore#getType()() ` Returns the type of this `CertStore`. |

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

### CertStore

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

```
protected CertStore (CertStoreSpi storeSpi, 
                Provider provider, 
                String type, 
                CertStoreParameters params)
```

Creates a `CertStore` object of the given type, and encapsulates the given provider implementation (SPI object) in it.

<br />

| Parameters ||
|---|---|
| `storeSpi` | `CertStoreSpi`: the provider implementation <br /> |
| `provider` | `Provider`: the provider <br /> |
| `type` | `String`: the type <br /> |
| `params` | `CertStoreParameters`: the initialization parameters (may be `null`) <br /> |

## Public methods

### getCRLs

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

```
public final Collection<? extends CRL> getCRLs (CRLSelector selector)
```

Returns a `Collection` of `CRL`s that match the specified selector. If no `CRL`s match the selector, an empty `Collection` will be returned.

For some `CertStore` types, the resulting `Collection` may not contain **all** of the `CRL`s that match the selector. For instance, an LDAP `CertStore` may not search all entries in the directory. Instead, it may just search entries that are likely to contain the `CRL`s it is looking for.

Some `CertStore` implementations (especially LDAP `CertStore`s) may throw a `CertStoreException` unless a non-null `CRLSelector` is provided that includes specific criteria that can be used to find the CRLs. Issuer names and/or the certificate to be checked are especially useful.

<br />

| Parameters ||
|---|---|
| `selector` | `CRLSelector`: A `CRLSelector` used to select which `CRL`s should be returned. Specify `null` to return all `CRL`s (if supported). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/security/cert/CRL>` | A `Collection` of `CRL`s that match the specified selector (never `null`) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStoreException` | if an exception occurs |

### getCertStoreParameters

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

```
public final CertStoreParameters getCertStoreParameters ()
```

Returns the parameters used to initialize this `CertStore`. Note that the `CertStoreParameters` object is cloned before it is returned.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStoreParameters` | the parameters used to initialize this `CertStore` (may be `null`) <br /> |

### getCertificates

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

```
public final Collection<? extends Certificate> getCertificates (CertSelector selector)
```

Returns a `Collection` of `Certificate`s that match the specified selector. If no `Certificate`s match the selector, an empty `Collection` will be returned.

For some `CertStore` types, the resulting `Collection` may not contain **all** of the `Certificate`s that match the selector. For instance, an LDAP `CertStore` may not search all entries in the directory. Instead, it may just search entries that are likely to contain the `Certificate`s it is looking for.

Some `CertStore` implementations (especially LDAP `CertStore`s) may throw a `CertStoreException` unless a non-null `CertSelector` is provided that includes specific criteria that can be used to find the certificates. Issuer and/or subject names are especially useful criteria.

<br />

| Parameters ||
|---|---|
| `selector` | `CertSelector`: A `CertSelector` used to select which `Certificate`s should be returned. Specify `null` to return all `Certificate`s (if supported). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/security/cert/Certificate>` | A `Collection` of `Certificate`s that match the specified selector (never `null`) <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStoreException` | if an exception occurs |

### getDefaultType

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

```
public static final String getDefaultType ()
```

Returns the default `CertStore` type as specified by the `certstore.type` security property, or the string "LDAP" if no such property exists.

The default `CertStore` type can be used by applications that do not want to use a hard-coded type when calling one of the `getInstance` methods, and want to provide a default `CertStore` type in case a user does not specify its own.

The default `CertStore` type can be changed by setting the value of the `certstore.type` security property to the desired type.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the default `CertStore` type as specified by the `certstore.type` security property, or the string "LDAP" if no such property exists. <br /> |

**See also:**

- `https://developer.android.com/reference/java/security/Security`

### getInstance

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

```
public static CertStore getInstance (String type, 
                CertStoreParameters params)
```

Returns a `CertStore` object that implements the specified `CertStore` type and is initialized with the specified parameters.

This method traverses the list of registered security Providers, starting with the most preferred Provider. A new CertStore object encapsulating the CertStoreSpi implementation from the first Provider that supports the specified type is returned.

Note that the list of registered providers may be retrieved via the `https://developer.android.com/reference/java/security/Security#getProviders()` method.

The `CertStore` that is returned is initialized with the specified `CertStoreParameters`. The type of parameters needed may vary between different types of `CertStore`s. Note that the specified `CertStoreParameters` object is cloned.

<br />

##### Implementation Note:

- The JDK Reference Implementation additionally uses the `jdk.security.provider.preferred` `https://developer.android.com/reference/java/security/Security#getProperty(java.lang.String)` property to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned by `https://developer.android.com/reference/java/security/Security#getProviders()`.

| Parameters ||
|---|---|
| `type` | `String`: the name of the requested `CertStore` type. See the CertStore section in the [Java Security Standard Algorithm Names Specification](https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#certstore-types) for information about standard types. <br /> |
| `params` | `CertStoreParameters`: the initialization parameters (may be `null`). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStore` | a `CertStore` object that implements the specified `CertStore` type <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `type` is `null` |
| `https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException` | if the specified initialization parameters are inappropriate for this `CertStore` |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if no `Provider` supports a `CertStoreSpi` implementation for the specified type |

**See also:**

- `https://developer.android.com/reference/java/security/Provider`

### getInstance

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

```
public static CertStore getInstance (String type, 
                CertStoreParameters params, 
                Provider provider)
```

Returns a `CertStore` object that implements the specified `CertStore` type.

A new CertStore object encapsulating the CertStoreSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.

The `CertStore` that is returned is initialized with the specified `CertStoreParameters`. The type of parameters needed may vary between different types of `CertStore`s. Note that the specified `CertStoreParameters` object is cloned.

<br />

| Parameters ||
|---|---|
| `type` | `String`: the requested `CertStore` type. See the CertStore section in the [Java Security Standard Algorithm Names Specification](https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#certstore-types) for information about standard types. <br /> |
| `params` | `CertStoreParameters`: the initialization parameters (may be `null`). <br /> |
| `provider` | `Provider`: the provider. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStore` | a `CertStore` object that implements the specified type <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the `provider` is null |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `type` is `null` |
| `https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException` | if the specified initialization parameters are inappropriate for this `CertStore` |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if a `CertStoreSpi` implementation for the specified type is not available from the specified Provider object |

**See also:**

- `https://developer.android.com/reference/java/security/Provider`

### getInstance

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

```
public static CertStore getInstance (String type, 
                CertStoreParameters params, 
                String provider)
```

Returns a `CertStore` object that implements the specified `CertStore` type.

A new CertStore object encapsulating the CertStoreSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list.

Note that the list of registered providers may be retrieved via the `https://developer.android.com/reference/java/security/Security#getProviders()` method.

The `CertStore` that is returned is initialized with the specified `CertStoreParameters`. The type of parameters needed may vary between different types of `CertStore`s. Note that the specified `CertStoreParameters` object is cloned.

<br />

| Parameters ||
|---|---|
| `type` | `String`: the requested `CertStore` type. See the CertStore section in the [Java Security Standard Algorithm Names Specification](https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html#certstore-types) for information about standard types. <br /> |
| `params` | `CertStoreParameters`: the initialization parameters (may be `null`). <br /> |
| `provider` | `String`: the name of the provider. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/cert/CertStore` | a `CertStore` object that implements the specified type <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the `provider` is `null` or empty |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `type` is `null` |
| `https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException` | if the specified initialization parameters are inappropriate for this `CertStore` |
| `https://developer.android.com/reference/java/security/NoSuchAlgorithmException` | if a `CertStoreSpi` implementation for the specified type is not available from the specified provider |
| `https://developer.android.com/reference/java/security/NoSuchProviderException` | if the specified provider is not registered in the security provider list |

**See also:**

- `https://developer.android.com/reference/java/security/Provider`

### getProvider

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

```
public final Provider getProvider ()
```

Returns the provider of this `CertStore`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Provider` | the provider of this `CertStore` <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 `CertStore`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the type of this `CertStore` <br /> |