我正在用我已经拥有的公共密钥加密文本文件, 我有一个基本上从输入流中读取公钥的方法, 在下一行创建对象时,出现异常
public static PGPPublicKey readPublicKeyFromCol(InputStream in)
throws IOException, PGPException {
PGPPublicKey k =null;
in = PGPUtil.getDecoderStream(in);
PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in, new BcKeyFingerprintCalculator());// Exception thrown on this line
Iterator rIt = pgpPub.getKeyRings();
while (rIt.hasNext()) {
PGPPublicKeyRing kRing = (PGPPublicKeyRing) rIt.next();
Iterator kIt = kRing.getPublicKeys();
while (kIt.hasNext()) {
k = (PGPPublicKey) kIt.next();
if (k.isEncryptionKey()) {
return k;
}
}
}
return k;
}
这是几个小时前开始的工作,突然停止工作了, 没有更改代码中的任何内容。现在,以下是我遇到的例外情况
Exception in thread "main" org.bouncycastle.openpgp.PGPException: org.bouncycastle.openpgp.PGPEncryptedDataList found where PGPPublicKeyRing expected
有人曾遇到过此类错误吗? 感谢任何帮助