Tag: bouncycastle classnotfoundexception

bouncycastle提供程序找不到算法所需的类

我正在尝试使用bouncycastle使用公钥加密文件。 我以编程方式注册了提供程序: Security.addProvider(new BouncyCastleProvider()); 我成功创建了公钥对象。 当我使用PGPEncryptedDataGenerator加密文件时,我得到一个ClassNotFoundexception。 似乎提供者在运行时找不到这个类,虽然我知道我有它的jar … 我在tomcat上运行我的应用程序。 使用maven处理依赖关系 – 我放的充气城堡jar子是bcpg,bcprov,bcmail,bctsp。 我尝试使用1.4和1.6版本都没有成功。 我在maven插件中使用了“依赖层次结构”,用于在pom中进行eclipse和排除,以确保我的项目中没有多个版本的bouncycastle。 这是堆栈跟踪: org.bouncycastle.openpgp.PGPException: exception encrypting session key at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source) at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source) …..(web application stack trace and uninteresting stuff)….. Caused by: java.security.NoSuchAlgorithmException: No such algorithm: ElGamal/ECB/PKCS1Padding at javax.crypto.Cipher.getInstance(DashoA13*..) at org.bouncycastle.openpgp.PGPEncryptedDataGenerator$PubMethod.addSessionInfo(Unknown Source) … 42 more Caused by: java.security.NoSuchAlgorithmException: class configured for Cipher(provider: […]