LoadFromStoreCert(string, string, StoreLocation, bool, bool)
static
public static X509Certificate2 LoadFromStoreCert(string subject, string storeName, StoreLocation storeLocation, bool allowInvalid, bool server) Loads the newest matching certificate which has an accessible private key and is valid for the requested TLS role.
Parameters
subjectstring- The subject name to search for.
storeNamestring- The name of the certificate store.
storeLocationStoreLocation- The location of the certificate store.
allowInvalidbooltrueto include certificates which do not pass certificate-chain validation; otherwise,false.serverbooltrueto select a certificate valid for server authentication;falseto select one valid for client authentication.
Returns
The selected certificate.
Exceptions
System.InvalidOperationException- No suitable certificate was found.
