microsoft / referencesource

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
https://referencesource.microsoft.com/
MIT License
3.13k stars 1.26k forks source link

How to get key alias in a certificate #161

Closed leonard520 closed 2 years ago

leonard520 commented 2 years ago

I am able to parse the key alias from a certificate by keytool. However I don't know how to get it from X509Certificate2. Any one can suggest? Thanks.

─ keytool -list -v -keystore abc.pfx -storetype PKCS12 Enter keystore password:

WARNING WARNING WARNING

Keystore type: PKCS12 Keystore provider: SUN

Your keystore contains 1 entry

Alias name: xxxxx <-- This is the information I want Creation date: Nov 19, 2021 Entry type: PrivateKeyEntry

leonard520 commented 2 years ago

Use another library to achieve it.