简体   繁体   English

java.security.NoSuchAlgorithmException:在 jar 文件中找不到任何支持 RSA/NONE/PKCS1Padding 的提供程序

[英]java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/PKCS1Padding in jar-file

I do to decrypt and encrypt RSA, I use Cipher.getInstance("RSA/NONE/PKCS1Padding");我做解密和加密 RSA,我使用Cipher.getInstance("RSA/NONE/PKCS1Padding"); for it, and I added Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());为此,我添加了Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); and compile 'org.bouncycastle:bcprov-jdk16:1.45' to gradle-file.并将compile 'org.bouncycastle:bcprov-jdk16:1.45'为 gradle 文件。 So this project to run and work in Intellij Idea,所以这个项目在 Intellij Idea 中运行和工作,

But if I generate .jar file and to run it, I have:但是如果我生成 .jar 文件并运行它,我有:

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/PKCS1Padding
    at javax.crypto.Cipher.getInstance(Cipher.java:540) 

(generated .jar by ShadowJar task of gradle). (由 gradle 的 ShadowJar 任务生成的 .jar)。

Why my project in Intellij Idea - work!为什么我在 Intellij Idea 中的项目 - 工作! And in .jar-file - does not work?在 .jar 文件中 - 不起作用?

"RSA/NONE/PKCS1Padding" is not something that is available in default security providers of most JDKs. "RSA/NONE/PKCS1Padding"在大多数 JDK 的默认安全提供程序中不可用。 You can use "RSA/ECB/PKCS1Padding" which means the same thing, but uses the ECB name for backwards compatibility.您可以使用"RSA/ECB/PKCS1Padding"这意味着相同的事情,但使用 ECB 名称以实现向后兼容性。

The BouncyCastle provider does give access to "RSA/NONE/PKCS1Padding" , but then you need to query it specifically, because adding a provider to the provider list doesn't make it a default provider: BouncyCastle 提供程序确实可以访问"RSA/NONE/PKCS1Padding" ,但是您需要专门查询它,因为将提供程序添加到提供程序列表不会使其成为默认提供程序:

Cipher.getInstance("RSA/NONE/PKCS1Padding", "BC");

Probably built jar file doesn't contain the dependency org.bouncycastle:bcprov-jdk16:1.45 .可能构建的 jar 文件不包含依赖项org.bouncycastle:bcprov-jdk16:1.45
Please check this out Using Gradle to build a jar with dependencies请查看Using Gradle to build a jar with dependencies

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.security.NoSuchAlgorithmException:找不到支持Blowfish / ECB / PKCS5Padding的任何提供程序 - java.security.NoSuchAlgorithmException: Cannot find any provider supporting Blowfish/ECB/PKCS5Padding java.security.NoSuchAlgorithmException:找不到任何支持 AES/ECB/PKCS7PADDING 的提供商 - java.security.NoSuchAlgorithmException:Cannot find any provider supporting AES/ECB/PKCS7PADDING RSA / NONE / PKCS1Padding给出错误,如java.security.NoSuchAlgorithmException - RSA/NONE/PKCS1Padding giving error as java.security.NoSuchAlgorithmException java.security.NoSuchAlgorithmException:找不到任何支持AES的提供程序 - java.security.NoSuchAlgorithmException:cannot find any provider supporting AES junit java.security.NoSuchAlgorithmException:找不到任何支持的提供程序 - junit java.security.NoSuchAlgorithmException: Cannot find any provider supporting .java.security.NoSuchAlgorithmException:提供者Cryptix不提供算法RSA / PKCS1 - .java.security.NoSuchAlgorithmException: algorithm RSA/PKCS1 is not available from provider Cryptix java.security.NoSuchAlgorithmException:AES / ECB / PKCS5Padding - java.security.NoSuchAlgorithmException: AES/ECB/PKCS5Padding java.security.NoSuchAlgorithmException: RSA 签名不可用 - java.security.NoSuchAlgorithmException: RSA Signature not available 找不到任何支持 RSA/None/OAEPWITHSHA-256ANDMGF1PADDING 的提供程序 - Cannot find any provider supporting RSA/None/OAEPWITHSHA-256ANDMGF1PADDING Corda bootcamp-cordapp 抛出 java.security.NoSuchAlgorithmException: class 配置为 KeyPairGenerator (provider: BC) 找不到 - Corda bootcamp-cordapp throws java.security.NoSuchAlgorithmException: class configured for KeyPairGenerator (provider: BC) cannot be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM