0

能够通过添加以下内容来动态配置 Bouncy Castle:

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

但是当通过在 $JAVA_HOME/conf/security/java.security 属性文件中添加条目来静态完成时

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

还通过类路径添加了jar

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

错误是:

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)
4

0 回答 0