private static X509Certificate2 LoadCertificate(string certificateType, string certifcateLocation, string certKeyPassword)
{
try
{
if (certificateType == "file")
{
X509Certificate2 serverCertificate = new X509Certificate2(certifcateLocation, certKeyPassword);
//DisplayCertificateChain(m_serverCertificate);
bool verifyCert = serverCertificate.Verify();
logger.Debug("Server Certificate loaded from file, Subject=" + serverCertificate.Subject + ", valid=" + verifyCert + ".");
return serverCertificate;
}
else
{
StoreLocation store = (certificateType == "machinestore") ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;
return AppState.LoadCertificate(store, certifcateLocation, true);
}
}
catch (Exception excp)
{
logger.Error("Exception LoadCertificate. " + excp.Message);
return null;
}
}