GenerateCertificate() public method

Generate a new certificate.
public GenerateCertificate ( string name, Usage usage, int validity ) : X509Certificate2
name string Name (subject) of the certificate
usage Usage Usage of the certificate
validity int Validity of the certificate or 0 to use the default validity
return System.Security.Cryptography.X509Certificates.X509Certificate2
示例#1
0
        static void Main(string[] args)
        {
            try
            {
                ShowInformation();
                ProgramOptions options = ParseCommandLine(args);
                if (options == null)
                {
                    return;
                }

                StoreLocation store = options.MachineStore ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;

                CertificatesAuthority ca = new CertificatesAuthority(options.AuthorityName, store);
                if (options.Pkcs10File != null)
                {
                    ca.SignRequest(options.Pkcs10File, options.Usage, 0);
                }
                else
                {
                    ca.GenerateCertificate(options.CertificateName, options.Usage, 0);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                ShowInformation();
                ProgramOptions options = ParseCommandLine(args);
                if(options == null)
                    return;

                StoreLocation store = options.MachineStore ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;

                CertificatesAuthority ca = new CertificatesAuthority(options.AuthorityName, store);
                if(options.Pkcs10File != null)
                    ca.SignRequest(options.Pkcs10File, options.Usage, 0);
                else
                    ca.GenerateCertificate(options.CertificateName, options.Usage, 0);
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }