Advtools.ADVpki.CertificatesAuthority.GenerateCertificate C# (CSharp) Метод

GenerateCertificate() публичный Метод

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
Результат System.Security.Cryptography.X509Certificates.X509Certificate2
        public MSX509.X509Certificate2 GenerateCertificate(string name, Usage usage, int validity)
        {
            MSX509.X509Certificate2 root = GetRootCertificate();
            if(null == root && usage != Usage.Authority)
                throw new ApplicationException("Root certificate not found");

            return InternalGenerateCertificate(X509NameFromString(name), usage, validity, MSX509.StoreName.My, root);
        }

Usage Example

Пример #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);
            }
        }
All Usage Examples Of Advtools.ADVpki.CertificatesAuthority::GenerateCertificate