![](/img/trans.png)
[英]How to add a certificate to the root trusted certificate but no alert window in C#
[英]How can I get the expiration date of an intermediate certificate and trusted root certificate by C# code?
使用X509Certificate.GetExpirationDateString方法 。
要获取证书,请使用:
X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certs = store.Certificates.Find(
X509FindType.FindBySubjectDistinguishedName,
"name",
false);
X509Certificate2 cert = certs[0];
cert.GetExpirationDateString();
我没有包括异常处理和检查是否清晰。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.