# PKIXBuilderParameters

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

# PKIXBuilderParameters

`
public


class
PKIXBuilderParameters
`  
`


``

extends `[PKIXParameters](https://developer.android.com/reference/java/security/cert/PKIXParameters)`


``


`

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

<br />

*** ** * ** ***

Parameters used as input for the PKIX`CertPathBuilder`algorithm.

A PKIX`CertPathBuilder`uses these parameters to[build](https://developer.android.com/reference/java/security/cert/CertPathBuilder#build(java.security.cert.CertPathParameters))a`CertPath`which has been validated according to the PKIX certification path validation algorithm.

To instantiate a`PKIXBuilderParameters`object, an application must specify one or more*most-trusted CAs* as defined by the PKIX certification path validation algorithm. The most-trusted CA can be specified using one of two constructors. An application can call[PKIXBuilderParameters(Set, CertSelector)](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#PKIXBuilderParameters(java.util.Set<java.security.cert.TrustAnchor>,%20java.security.cert.CertSelector)), specifying a`Set`of`TrustAnchor`objects, each of which identifies a most-trusted CA. Alternatively, an application can call[PKIXBuilderParameters(KeyStore, CertSelector)](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#PKIXBuilderParameters(java.security.KeyStore,%20java.security.cert.CertSelector)), specifying a`KeyStore`instance containing trusted certificate entries, each of which will be considered as a most-trusted CA.

In addition, an application must specify constraints on the target certificate that the`CertPathBuilder`will attempt to build a path to. The constraints are specified as a`CertSelector`object. These constraints should provide the`CertPathBuilder`with enough search criteria to find the target certificate. Minimal criteria for an`X509Certificate`usually include the subject name and/or one or more subject alternative names. If enough criteria is not specified, the`CertPathBuilder`may throw a`CertPathBuilderException`.

**Concurrent Access**

Unless otherwise specified, the methods defined in this class are not thread-safe. Multiple threads that need to access a single object concurrently should synchronize amongst themselves and provide the necessary locking. Multiple threads each manipulating separate objects need not synchronize.  
**See also:**

- [CertPathBuilder](https://developer.android.com/reference/java/security/cert/CertPathBuilder)

## Summary

|                                                                                                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                                                                                                         ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[PKIXBuilderParameters](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#PKIXBuilderParameters(java.security.KeyStore,%20java.security.cert.CertSelector))`(`[KeyStore](https://developer.android.com/reference/java/security/KeyStore)` keystore, `[CertSelector](https://developer.android.com/reference/java/security/cert/CertSelector)` targetConstraints) ` Creates an instance of`PKIXBuilderParameters`that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified`KeyStore`.                             |
| ` `[PKIXBuilderParameters](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#PKIXBuilderParameters(java.util.Set<java.security.cert.TrustAnchor>,%20java.security.cert.CertSelector))`(`[Set](https://developer.android.com/reference/java/util/Set)`<`[TrustAnchor](https://developer.android.com/reference/java/security/cert/TrustAnchor)`> trustAnchors, `[CertSelector](https://developer.android.com/reference/java/security/cert/CertSelector)` targetConstraints) ` Creates an instance of`PKIXBuilderParameters`with the specified`Set`of most-trusted CAs. |

|                                                                                                                                                                  ### Public methods                                                                                                                                                                  ||
|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`                                                                | ` `[getMaxPathLength](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#getMaxPathLength())`() ` Returns the value of the maximum number of intermediate non-self-issued certificates that may exist in a certification path.                  |
| ` void`                                                               | ` `[setMaxPathLength](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#setMaxPathLength(int))`(int maxPathLength) ` Sets the value of the maximum number of non-self-issued intermediate certificates that may exist in a certification path. |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#toString())`() ` Returns a formatted string describing the parameters.                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.security.cert.PKIXParameters](https://developer.android.com/reference/java/security/cert/PKIXParameters)` ` |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                                                                                                      | ` `[addCertPathChecker](https://developer.android.com/reference/java/security/cert/PKIXParameters#addCertPathChecker(java.security.cert.PKIXCertPathChecker))`(`[PKIXCertPathChecker](https://developer.android.com/reference/java/security/cert/PKIXCertPathChecker)` checker) ` Adds a`PKIXCertPathChecker`to the list of certification path checkers.                                                                                                                                                           | | ` void`                                                                                                                                                                      | ` `[addCertStore](https://developer.android.com/reference/java/security/cert/PKIXParameters#addCertStore(java.security.cert.CertStore))`(`[CertStore](https://developer.android.com/reference/java/security/cert/CertStore)` store) ` Adds a`CertStore`to the end of the list of`CertStore`s used in finding certificates and CRLs.                                                                                                                                                                                | | ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                                        | ` `[clone](https://developer.android.com/reference/java/security/cert/PKIXParameters#clone())`() ` Makes a copy of this`PKIXParameters`object.                                                                                                                                                                                                                                                                                                                                                                     | | ` `[List](https://developer.android.com/reference/java/util/List)`<`[PKIXCertPathChecker](https://developer.android.com/reference/java/security/cert/PKIXCertPathChecker)`>` | ` `[getCertPathCheckers](https://developer.android.com/reference/java/security/cert/PKIXParameters#getCertPathCheckers())`() ` Returns the`List`of certification path checkers.                                                                                                                                                                                                                                                                                                                                    | | ` `[List](https://developer.android.com/reference/java/util/List)`<`[CertStore](https://developer.android.com/reference/java/security/cert/CertStore)`>`                     | ` `[getCertStores](https://developer.android.com/reference/java/security/cert/PKIXParameters#getCertStores())`() ` Returns an immutable`List`of`CertStore`s that are used to find certificates and CRLs.                                                                                                                                                                                                                                                                                                           | | ` `[Date](https://developer.android.com/reference/java/util/Date)                                                                                                            | ` `[getDate](https://developer.android.com/reference/java/security/cert/PKIXParameters#getDate())`() ` Returns the time for which the validity of the certification path should be determined.                                                                                                                                                                                                                                                                                                                     | | ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>`                                      | ` `[getInitialPolicies](https://developer.android.com/reference/java/security/cert/PKIXParameters#getInitialPolicies())`() ` Returns an immutable`Set`of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing.                                                                                                                                                                        | | ` boolean`                                                                                                                                                                   | ` `[getPolicyQualifiersRejected](https://developer.android.com/reference/java/security/cert/PKIXParameters#getPolicyQualifiersRejected())`() ` Gets the PolicyQualifiersRejected flag.                                                                                                                                                                                                                                                                                                                             | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                        | ` `[getSigProvider](https://developer.android.com/reference/java/security/cert/PKIXParameters#getSigProvider())`() ` Returns the signature provider's name, or`null`if not set.                                                                                                                                                                                                                                                                                                                                    | | ` `[CertSelector](https://developer.android.com/reference/java/security/cert/CertSelector)                                                                                   | ` `[getTargetCertConstraints](https://developer.android.com/reference/java/security/cert/PKIXParameters#getTargetCertConstraints())`() ` Returns the required constraints on the target certificate.                                                                                                                                                                                                                                                                                                               | | ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[TrustAnchor](https://developer.android.com/reference/java/security/cert/TrustAnchor)`>`                   | ` `[getTrustAnchors](https://developer.android.com/reference/java/security/cert/PKIXParameters#getTrustAnchors())`() ` Returns an immutable`Set`of the most-trusted CAs.                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                                                                                   | ` `[isAnyPolicyInhibited](https://developer.android.com/reference/java/security/cert/PKIXParameters#isAnyPolicyInhibited())`() ` Checks whether the any policy OID should be processed if it is included in a certificate.                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                                                                                   | ` `[isExplicitPolicyRequired](https://developer.android.com/reference/java/security/cert/PKIXParameters#isExplicitPolicyRequired())`() ` Checks if explicit policy is required.                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                                                   | ` `[isPolicyMappingInhibited](https://developer.android.com/reference/java/security/cert/PKIXParameters#isPolicyMappingInhibited())`() ` Checks if policy mapping is inhibited.                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                                                   | ` `[isRevocationEnabled](https://developer.android.com/reference/java/security/cert/PKIXParameters#isRevocationEnabled())`() ` Checks the RevocationEnabled flag.                                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                                                                                      | ` `[setAnyPolicyInhibited](https://developer.android.com/reference/java/security/cert/PKIXParameters#setAnyPolicyInhibited(boolean))`(boolean val) ` Sets state to determine if the any policy OID should be processed if it is included in a certificate.                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                                      | ` `[setCertPathCheckers](https://developer.android.com/reference/java/security/cert/PKIXParameters#setCertPathCheckers(java.util.List<java.security.cert.PKIXCertPathChecker>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[PKIXCertPathChecker](https://developer.android.com/reference/java/security/cert/PKIXCertPathChecker)`> checkers) ` Sets a`List`of additional certification path checkers.                                                                                      | | ` void`                                                                                                                                                                      | ` `[setCertStores](https://developer.android.com/reference/java/security/cert/PKIXParameters#setCertStores(java.util.List<java.security.cert.CertStore>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[CertStore](https://developer.android.com/reference/java/security/cert/CertStore)`> stores) ` Sets the list of`CertStore`s to be used in finding certificates and CRLs.                                                                                                               | | ` void`                                                                                                                                                                      | ` `[setDate](https://developer.android.com/reference/java/security/cert/PKIXParameters#setDate(java.util.Date))`(`[Date](https://developer.android.com/reference/java/util/Date)` date) ` Sets the time for which the validity of the certification path should be determined.                                                                                                                                                                                                                                     | | ` void`                                                                                                                                                                      | ` `[setExplicitPolicyRequired](https://developer.android.com/reference/java/security/cert/PKIXParameters#setExplicitPolicyRequired(boolean))`(boolean val) ` Sets the ExplicitPolicyRequired flag.                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                                      | ` `[setInitialPolicies](https://developer.android.com/reference/java/security/cert/PKIXParameters#setInitialPolicies(java.util.Set<java.lang.String>))`(`[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`> initialPolicies) ` Sets the`Set`of initial policy identifiers (OID strings), indicating that any one of these policies would be acceptable to the certificate user for the purposes of certification path processing. | | ` void`                                                                                                                                                                      | ` `[setPolicyMappingInhibited](https://developer.android.com/reference/java/security/cert/PKIXParameters#setPolicyMappingInhibited(boolean))`(boolean val) ` Sets the PolicyMappingInhibited flag.                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                                      | ` `[setPolicyQualifiersRejected](https://developer.android.com/reference/java/security/cert/PKIXParameters#setPolicyQualifiersRejected(boolean))`(boolean qualifiersRejected) ` Sets the PolicyQualifiersRejected flag.                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                                      | ` `[setRevocationEnabled](https://developer.android.com/reference/java/security/cert/PKIXParameters#setRevocationEnabled(boolean))`(boolean val) ` Sets the RevocationEnabled flag.                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                                      | ` `[setSigProvider](https://developer.android.com/reference/java/security/cert/PKIXParameters#setSigProvider(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` sigProvider) ` Sets the signature provider's name.                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                                      | ` `[setTargetCertConstraints](https://developer.android.com/reference/java/security/cert/PKIXParameters#setTargetCertConstraints(java.security.cert.CertSelector))`(`[CertSelector](https://developer.android.com/reference/java/security/cert/CertSelector)` selector) ` Sets the required constraints on the target certificate.                                                                                                                                                                                 | | ` void`                                                                                                                                                                      | ` `[setTrustAnchors](https://developer.android.com/reference/java/security/cert/PKIXParameters#setTrustAnchors(java.util.Set<java.security.cert.TrustAnchor>))`(`[Set](https://developer.android.com/reference/java/util/Set)`<`[TrustAnchor](https://developer.android.com/reference/java/security/cert/TrustAnchor)`> trustAnchors) ` Sets the`Set`of most-trusted CAs.                                                                                                                                          | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                        | ` `[toString](https://developer.android.com/reference/java/security/cert/PKIXParameters#toString())`() ` Returns a formatted string describing the parameters.                                                                                                                                                                                                                                                                                                                                                     | ||
| 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*.                                                                                             | ||
| From interface` `[java.security.cert.CertPathParameters](https://developer.android.com/reference/java/security/cert/CertPathParameters)` ` |--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[clone](https://developer.android.com/reference/java/security/cert/CertPathParameters#clone())`() ` Makes a copy of this`CertPathParameters`. | ||

## Public constructors

### PKIXBuilderParameters

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

```
public PKIXBuilderParameters (KeyStore keystore, 
                CertSelector targetConstraints)
```

Creates an instance of`PKIXBuilderParameters`that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified`KeyStore`. Only keystore entries that contain trusted`X509Certificate`s are considered; all other certificate types are ignored.

<br />

|                                                   Parameters                                                    ||
|---------------------|--------------------------------------------------------------------------------------------|
| `keystore`          | `KeyStore`: a`KeyStore`from which the set of most-trusted CAs will be populated <br />     |
| `targetConstraints` | `CertSelector`: a`CertSelector`specifying the constraints on the target certificate <br /> |

|                                                                                               Throws                                                                                                ||
|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| [KeyStoreException](https://developer.android.com/reference/java/security/KeyStoreException)                                   | if`keystore`has not been initialized                                |
| [InvalidAlgorithmParameterException](https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException) | if`keystore`does not contain at least one trusted certificate entry |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)                                 | if`keystore`is`null`                                                |

### PKIXBuilderParameters

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

```
public PKIXBuilderParameters (Set<TrustAnchor> trustAnchors, 
                CertSelector targetConstraints)
```

Creates an instance of`PKIXBuilderParameters`with the specified`Set`of most-trusted CAs. Each element of the set is a[TrustAnchor](https://developer.android.com/reference/java/security/cert/TrustAnchor).

Note that the`Set`is copied to protect against subsequent modifications.

<br />

|                                                   Parameters                                                    ||
|---------------------|--------------------------------------------------------------------------------------------|
| `trustAnchors`      | `Set`: a`Set`of`TrustAnchor`s <br />                                                       |
| `targetConstraints` | `CertSelector`: a`CertSelector`specifying the constraints on the target certificate <br /> |

|                                                                                                         Throws                                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [InvalidAlgorithmParameterException](https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException) | if`trustAnchors`is empty`(trustAnchors.isEmpty() == true)`                             |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)                                 | if`trustAnchors`is`null`                                                               |
| [ClassCastException](https://developer.android.com/reference/java/lang/ClassCastException)                                     | if any of the elements of`trustAnchors`are not of type`java.security.cert.TrustAnchor` |

## Public methods

### getMaxPathLength

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

```
public int getMaxPathLength ()
```

Returns the value of the maximum number of intermediate non-self-issued certificates that may exist in a certification path. See the[setMaxPathLength(int)](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#setMaxPathLength(int))method for more details.

<br />

|                                                                     Returns                                                                      ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the maximum number of non-self-issued intermediate certificates that may exist in a certification path, or -1 if there is no limit <br /> |

**See also:**

- [setMaxPathLength(int)](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#setMaxPathLength(int))  

### setMaxPathLength

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

```
public void setMaxPathLength (int maxPathLength)
```

Sets the value of the maximum number of non-self-issued intermediate certificates that may exist in a certification path. A certificate is self-issued if the DNs that appear in the subject and issuer fields are identical and are not empty. Note that the last certificate in a certification path is not an intermediate certificate, and is not included in this limit. Usually the last certificate is an end entity certificate, but it can be a CA certificate. A PKIX`CertPathBuilder`instance must not build paths longer than the length specified.

A value of 0 implies that the path can only contain a single certificate. A value of -1 implies that the path length is unconstrained (i.e. there is no maximum). The default maximum path length, if not specified, is 5. Setting a value less than -1 will cause an exception to be thrown.

If any of the CA certificates contain the`BasicConstraintsExtension`, the value of the`pathLenConstraint`field of the extension overrides the maximum path length parameter whenever the result is a certification path of smaller length.

<br />

|                                                              Parameters                                                               ||
|-----------------|----------------------------------------------------------------------------------------------------------------------|
| `maxPathLength` | `int`: the maximum number of non-self-issued intermediate certificates that may exist in a certification path <br /> |

|                                                                            Throws                                                                             ||
|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [InvalidParameterException](https://developer.android.com/reference/java/security/InvalidParameterException) | if`maxPathLength`is set to a value less than -1 |

**See also:**

- [getMaxPathLength()](https://developer.android.com/reference/java/security/cert/PKIXBuilderParameters#getMaxPathLength())  

### toString

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

```
public String toString ()
```

Returns a formatted string describing the parameters.

<br />

|                                                         Returns                                                         ||
|--------------------------------------------------------------------|-----------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a formatted string describing the parameters <br /> |