Save a certificate object to file - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Certificate

Description

Save a certificate object to file

Demo Code


using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography;
using System.IO;/*  w  w  w.  j av a 2s .  c  o  m*/
using System.Diagnostics;
using System.Threading;
using System.Resources;
using System.Reflection.Emit;
using System.Reflection;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// Save a certificate object to file
        /// </summary>
        /// <param name="Cert"></param>
        /// <param name="FileName"></param>
        public static void SaveCert(X509Certificate2 Cert, string FileName)
        {
            try
            {
                File.WriteAllBytes(FileName, Cert.RawData);
            }
            catch { }

            return;
        }
}

Related Tutorials