0

Able to configure Bouncy Castle dynamically by adding below:

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

but when done statically by adding entry in $JAVA_HOME/conf/security/java.security properties file

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=SunPKCS11
security.provider.13=org.bouncycastle.jce.provider.BouncyCastleProvider

also added the jar via classpath like

exec java  -cp "/opt/app/lib/bcprov-jdk15on-165.jar;/opt/app/lib/*"  -jar ${JAR_FILE} &

Error is:

Caused by: java.security.NoSuchProviderException: no such provider: BC
        at java.base/sun.security.jca.GetInstance.getService(GetInstance.java:83)
        at java.base/javax.crypto.JceSecurity.getInstance(JceSecurity.java:129)
        at java.base/javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:208)
        at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:689)
  • You might need to add the jar to the lib\ext dir - see https://stackoverflow.com/a/19585398/1184752 – Juraj Martinka Jul 01 '20 at 03:58
  • @JurajMartinka the \jre\lib\ext\ is no more available in jdk14 and have added the jar in classpath, it doesn't still load the provider – Abhinav Gupta Jul 03 '20 at 03:54
  • You can't use `-cp` and `-jar` at the same time. So I don't think this is anything to do with JDK 14 or BC specifically, it's just that you don't have the class path set correctly. – Alan Bateman Aug 07 '20 at 07:20

0 Answers0