【发布时间】:2018-06-22 18:44:39
【问题描述】:
我想生成吊销证书以及公钥和私钥对生成。
正确生成私钥和公钥。
我试着这样做:
public void generateRevoke(String id, PGPPublicKey pk, PGPSecretKey secretKey, char[] passPhrase, OutputStream out) throws PGPException, IOException {
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(
new JcaPGPContentSignerBuilder(secretKey.getPublicKey().getAlgorithm(), PGPUtil.SHA1));
PGPPrivateKey pgpPrivKey = secretKey.extractPrivateKey(
new JcePBESecretKeyDecryptorBuilder().setProvider(new BouncyCastleProvider())
.build(passPhrase));
signatureGenerator.init(PGPSignature.KEY_REVOCATION, pgpPrivKey);
PGPSignature signature = signatureGenerator.generateCertification(id, pk);
PGPPublicKey key = PGPPublicKey.addCertification(pk, id, signature);
key.encode(new ArmoredOutputStream(out));
}
但在输出文件中我得到的是 PGP MESSAGE 而不是 PGP PUBLIC KEY
我做错了什么?
【问题讨论】:
标签: java bouncycastle pgp