java GPEncryptedCatalist找到了PGPPubliceRing预期的位置
我正在用我已有的公钥加密一个文本文件, 我有一个方法,基本上是从输入流读取公钥, 在下一行创建对象时,我遇到异常
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
以前有人遇到过这种错误吗? 谢谢你在这方面的帮助
共 (0) 个答案