Skip to content

Provider Installation

dghgit edited this page Aug 2, 2020 · 1 revision

Subject to class loader constraints the Bouncy Castle Provider can be installed either dynamically or statically.

Note: to make full use of the provider you must install the unlimited policy files in the JVM you are using - these can be downloaded from http://java.sun.com. Be careful if you are using Windows as the JDK install will normally install a JRE and a JDK in two separate places - generally both of these will need to have the policy files installed in it.

Installing the Provider Dynamically

import org.bouncycastle.jce.provider.BouncyCastleProvider;
...
Security.addProvider(new BouncyCastleProvider());

Installing the Provider Statically

To install the provider statically you need to add it as an entry to the java.security file which can be found in $JAVA_HOME/jre/lib/security/java.security for the JRE/JDK you are using. Look for a list of lines with security.provider.X where X is some number. At the bottom of the list add the line:

security.provider.N=org.bouncycastle.jce.provider.BouncyCastleProvider

where N is one more than the last number in the list.

It is possible to add the provider higher up in the list. If you do this we recommend you don't add it earlier than position 2 as there are occasionally internal dependencies on the provider at position 1 which may cause some operations by your JVM to result in errors.