Spring boot Spring引导和JCA提供程序

Spring boot Spring引导和JCA提供程序,spring-boot,bouncycastle,jce,Spring Boot,Bouncycastle,Jce,我有一个Spring boot(1.4.2.RELEASE)项目,其中bouncycastle作为pom.xml中的依赖项,如下所示: pom.xml ... <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcprov-jdk15on</artifactId> <version>1.54</version> </depe

我有一个Spring boot(1.4.2.RELEASE)项目,其中bouncycastle作为pom.xml中的依赖项,如下所示:

pom.xml
...
<dependency>
  <groupId>org.bouncycastle</groupId>
  <artifactId>bcprov-jdk15on</artifactId>
  <version>1.54</version>
</dependency>
<dependency>
  <groupId>org.bouncycastle</groupId>
  <artifactId>bcpkix-jdk15on</artifactId>
  <version>1.54</version>
</dependency>
...
我可以毫无问题地访问其中的类,但JCA找不到提供程序

那么,JCA是否要求提供者JAR位于jre/lib/ext中

…还是我只是错过了什么

编辑:

然而,这:

Signature.getInstance(“SHA256withRSA”,新的BouncyCastleProvider())


有效。

在使用Bouncycastle提供程序之前,您需要安装它。看

动态安装提供程序

import org.bouncycastle.jce.provider.BouncyCastleProvider;
...
Security.addProvider(new BouncyCastleProvider());
静态安装提供程序

import org.bouncycastle.jce.provider.BouncyCastleProvider;
...
Security.addProvider(new BouncyCastleProvider());
$JAVA\u HOME/jre/lib/security/JAVA.security

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

将Bouncy Castle提供程序jar添加到
$JAVA_HOME/jre/lib/ext

我执行静态安装…请参阅我的原始帖子。然后,您需要将jar添加到
jre/lib/ext
,也不要使用positión 1,因为“Bouncy Castle”可能有依赖项。请参阅Oracle的此链接,其中引用了bouncycastle。在这些链接中,还指出需要将JAR包含到JVM
lib/ext
中,感谢您的回复……我非常感谢。至于您的评论,原因是:signature.getInstance(“SHA256withRSA”,new BouncyCastleProvider());工作但签名.getInstance(“SHA256withRSA”,“BC”);当JAR不在jre/lib/ext文件夹中时失败?我想这是类加载器的问题。JAR不在jre/lib/ext
中时的静态初始化失败,因为提供程序实例化是由JVM完成的,并且应用程序的类路径在全局不可见。您可能会在一些日志中发现错误
signature.getInstance(“SHA256withRSA”、“BC”)
经常失败,因为提供程序未初始化
new BouncyCastleProvider()
使用应用程序类路径以友好方式实例化提供程序,因此bouncycastle JAR可见
signature.getInstance()
将使用最近创建的提供程序并工作。既然不再有lib/ext文件夹,在JDK11中如何执行此操作?