Search code examples
javabouncycastleprovider

Installing the Bouncy Castle Provider in java version "15.0.1"


I need to install this provider in windows 10. This is the java version:

java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

Now, I changed the java.security file to

Java\jdk-15.0.1\conf\security

I added the provider like this:

# List of providers and their preference orders (see above):
#
security.provider.1=SUN
security.provider.2=SunRsaSign
security.provider.3=SunEC
security.provider.4=SunJSSE
security.provider.5=SunJCE
security.provider.6=SunJGSS
security.provider.7=SunSASL
security.provider.8=XMLDSig
security.provider.9=SunPCSC
security.provider.10=JdkLDAP
security.provider.11=JdkSASL
security.provider.12=SunMSCAPI
security.provider.13=SunPKCS11
security.provider.14=org.bouncycastle.jce.provider.BouncyCastleProvider

In this version of Java where should jar files be placed? I don't have the \lib\ext path

Did I edit the correct file?


Solution

  • if you are using Maven then add BouncyCastle dependency in pom.xml.

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-ext-jdk15to18</artifactId>
        <version>1.67</version>
    </dependency>
    

    Later, you can dynamically add BouncyCastleProvider using below line when you need it.

    Security.addProvider(new BouncyCastleProvider());
    

    To add statically,

    Add the Bouncy Castle provider jar to the $JAVA_HOME/jre/lib/ext directory

    add below line in this file {JAVA_HOME}/jre/lib/security/java.security

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