'How to add expiry date when generating Bouncy Castle PGP key pair?
I was following https://bouncycastle-pgp-cookbook.blogspot.com/ to generate the PGP key pair. It worked well with pub and private key files generated. But when I look at the pub key, it does not have expiry date. I set key expiration time on PGPSignatureSubpacketGenerator. signhashgen.setKeyExpirationTime(true, 864000);
Solution 1:[1]
It took me a few hours to figure out the answer. Since I have two subpackets in the PGPKeyPair, I have to set expiration date on both subpackets. Then the expiration date will show in certificate and subkey details as shown in the screenshot.

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Janet |
