Get Certificate From File - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Certificate

Description

Get Certificate From File

Demo Code

// Copyright (c) Microsoft. All rights reserved.
using System.Security.Cryptography.X509Certificates;
using System.IO;//from   w ww .ja  v a2  s  . c o  m
using System.Collections.Concurrent;

public class Main{
        public static X509Certificate2 GetCertificateFromFile(string fileName, string password)
        {
            X509Certificate2 certificate;
            if (certificatesFromFiles.TryGetValue(fileName, out certificate))
            {
                return certificate;
            }

            certificate = new X509Certificate2(fileName, password, X509KeyStorageFlags.Exportable);
            certificatesFromFiles[fileName] = certificate;
            return certificate;
        }
}

Related Tutorials