我使用以下网址
在线创建了PGP私钥和公钥姓名:测试
电子邮件:test@domain.com
算法:RSA
密钥大小:1024
过期:2年
密码:测试
公钥
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Keybase OpenPGP v1.0.0
Comment: https://keybase.io/crypto
xo0EWaVVewEEALOBxiFQ5Y9f8QHouZKrxZPe6RuaLWUNl0maY/iQn/cBZ5WjNxQn
yN0Nzki/+0l8eqfvAbB7jStmOQEthhlnSqSkq8HfSJxQMr3kGjVS5ijXmYFmR2/y
5+IUizjMhLLPIFD0z607yVbDUTwXAjJP0EB75rABErV2CkM062KxE4pzABEBAAHN
FnRlc3QgPHRlc3RAZG9tYWluLmNvbT7CrQQTAQoAFwUCWaVVewIbLwMLCQcDFQoI
Ah4BAheAAAoJEOM5TJlGW7I5KAID/jkPUnbuOOD5UtK3jnLPwaQSpUY/3E4+xoMU
NykQr+nNqEti2FcX1Hj0C1TVh1ZnMzSQiLAe1hNOVsL8le6fUOHqhA+iURmtLG/4
dNLyZHqhV7jgxT+c752Io7Nq7vtSxFowZFnx5Vq3NZLKt6AXrOpCL1NvcStAIU7S
2E+ed6y0zo0EWaVVewEEAKZGk4tVAXmN12xFAwJ50tLNWXy2Yt5S/6b26pwNN6UI
vruCGOjOLBm+mzOxCn65AvUC6LmtY/FUe1bvEkX2BzcwzSBEeLOhWKVlC/HM17bt
CTTzYHT79EfQ4LFF0IEXlb/zcV/GrrZAWMWm/coJDW614xnJvBKEDDpY608YmHmr
ABEBAAHCwIMEGAEKAA8FAlmlVXsFCQ8JnAACGy4AqAkQ4zlMmUZbsjmdIAQZAQoA
BgUCWaVVewAKCRABpbX1cvywdWW5A/4rKjnOGhJmUPrgsJpcub0sWGwrKInlnm9C
GJ5YfjZmXslsi04+2vq7/fy7QbWjW5Opi/oXKmJpGombPpxgat8OaDyRtszkxkOw
H8h9TXd61EatIMca1aZUVIhgrW7QNcylamnCuDDxMmEIgDMLLBanxV1oW+VOvNXw
AGDu5Ao7D6xLA/0UbFY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E/
ecop57QltAsoSK9uTwxFVrAkGs7SsRKHZ7OAFytu/UEftGb7kaQCYkIFHWsVWThO
Mam8/BQR3qtTaKCNgDar3o1Omejx0bTSdT6jNpZrKp82ZK0ULBXGraibA4s7rRKz
hJwQoxZqkTlOB+7KeDPqLphGI44zJ8k/cdlSJ09vhXyHmgXw4IJOlsdugUgAW2Ac
P98HRHHeIocV6EwxBxKVhqUn80jgMSm+LA8SKn29hXBB5zoeG2h7VNWZdw3xejz/
CTqkGIqPkjXOTXG6lk/AmhGO19qNQ8w/yhmljxg8OD+8T46ydGSh4/U3vzHWWgiG
F722UINLdKvXUvPdBlAvU2FasJGvqJz1aZvoVYD3gLNjlwGNo4eUl1lr6oH7XjB2
5gsd5JdPCF+aGq36cJImixFbkvEzGuPNBivfhGEdsFIfpKGpoI4EQYvgNxrb1wSU
z9YGWdsLHDEe3kRHVQGvx7xwQy3ltLthwsCDBBgBCgAPBQJZpVV7BQkPCZwAAhsu
AKgJEOM5TJlGW7I5nSAEGQEKAAYFAlmlVXsACgkQeedXyOefITNXuQP9E2/sk7M+
bscCakQNb0AuGqbiAlTRYEhIGaIfDQmYHPQAjT6EQuWjmDqvqBxKNUv8yOy7OFC3
G5Uh9mOQyMANI7c7EEwryUZKBgWTmbAuoCyJ49SG19/toWqPbhT28XyAXGm+kiy6
2dgply1Pa4jgVkhqeTdmvkgK6TiggI7psfvGFwP+JVJrJRpecmkhC68zJtYD3XyF
R9r3BRDDVVad3B3zh3TmJHjSygDDAV74gi5KUaADaoJrnopTu14i4wnYPn7Z03Ne
obLxdYBZ8Tlp2kdtdEBLlzU4rx8syA9EPKakwDHC3JaAq/P2sDtODzz1SY5lMksJ
F9PaPqyNEQjEAU7UBcA=
=HuWA
-----END PGP PRIVATE KEY BLOCK-----
我试图在C#中使用Bouncy Castle API找出密钥的到期日期。 以下是代码
private PgpPublicKey ReadPublicKey(string publicKeyPath)
{
using (Stream keyIn = File.OpenRead(publicKeyPath))
using (var inputStream = PgpUtilities.GetDecoderStream(keyIn))
{
var publicKeyRingBundle = new PgpPublicKeyRingBundle(inputStream);
var foundKey = GetFirstPublicKey(publicKeyRingBundle);
if (foundKey != null)
return foundKey;
}
throw new ArgumentException("No encryption key found in public key ring.");
}
private PgpPublicKey GetFirstPublicKey(PgpPublicKeyRingBundle publicKeyRingBundle)
{
foreach (PgpPublicKeyRing kRing in publicKeyRingBundle.GetKeyRings())
{
var key = kRing.GetPublicKeys()
.Cast<PgpPublicKey>()
.Where(k => k.IsEncryptionKey)
.FirstOrDefault();
if (key != null)
return key;
}
return null;
}
该函数被称为
PgpPublicKey key = ReadPublicKey(pathToPublicKey)
并尝试找出有效日期
key.ValidDays
但它总是返回0.即没有过期。
我能够访问其他属性,如密钥大小,名称和电子邮件等
我在这里想念的是什么?或者还有什么需要做的吗?