# CertificateLoader Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.connections.transport.security.certificateloader/)

## LoadFromStoreCert(string, string, StoreLocation, bool, bool) {#loadfromstorecert-string-string-system-security-cryptography-x509certificates-st-82ee3878}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.connections.transport.security.certificateloader/methods/loadfromstorecert-string-string-system-security-cryptography-x509certificates-st-82ee3878/)

[Source](https://github.com/dotnet/orleans/blob/fbe240c34e9a1389ca5ab2d52f292ed8749ea530/src/Orleans.Core/Networking/Transport/Security/CertificateLoader.cs#L38-L67)

```csharp
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

- `subject` (`string`): The subject name to search for.
- `storeName` (`string`): The name of the certificate store.
- `storeLocation` (`StoreLocation`): The location of the certificate store.
- `allowInvalid` (`bool`): `true` to include certificates which do not pass certificate-chain validation; otherwise, `false`.
- `server` (`bool`): `true` to select a certificate valid for server authentication; `false` to select one valid for client authentication.

### Returns

The selected certificate. The caller owns and disposes the certificate after its consumers have stopped.

### Exceptions

- `System.InvalidOperationException`: No suitable certificate was found.
