void initializeFromCOM(IX509CertificateTemplate template)
        {
            if (CryptographyUtils.TestOleCompat())
            {
                GeneralFlags      = (CertificateTemplateFlags)template.Property[EnrollmentTemplateProperty.TemplatePropGeneralFlags];
                EnrollmentOptions = (CertificateTemplateEnrollmentFlags)template.Property[EnrollmentTemplateProperty.TemplatePropEnrollmentFlags];
                subjectFlags      = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropSubjectNameFlags];
                ValidityPeriod    = readValidity(null, (Int64)template.Property[EnrollmentTemplateProperty.TemplatePropValidityPeriod]);
                RenewalPeriod     = readValidity(null, (Int64)template.Property[EnrollmentTemplateProperty.TemplatePropRenewalPeriod]);
            }
            else
            {
                GeneralFlags      = (CertificateTemplateFlags)Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropGeneralFlags]);
                EnrollmentOptions = (CertificateTemplateEnrollmentFlags)Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropEnrollmentFlags]);
                subjectFlags      = unchecked ((Int32)(UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropSubjectNameFlags]);
                ValidityPeriod    = readValidity(null, Convert.ToInt64((UInt64)template.Property[EnrollmentTemplateProperty.TemplatePropValidityPeriod]));
                RenewalPeriod     = readValidity(null, Convert.ToInt64((UInt64)template.Property[EnrollmentTemplateProperty.TemplatePropRenewalPeriod]));
            }
            try {
                SupersededTemplates = (String[])template.Property[EnrollmentTemplateProperty.TemplatePropSupersede];
            } catch {
                SupersededTemplates = Array.Empty <String>();
            }
            List <X509Extension> exts2 = (from IX509Extension ext in (IX509Extensions)template.Property[EnrollmentTemplateProperty.TemplatePropExtensions] select new X509Extension(ext.ObjectId.Value, Convert.FromBase64String(ext.RawData[Interop.CERTENROLLLib.EncodingType.XCN_CRYPT_STRING_BASE64]), ext.Critical)).Select(CryptographyUtils.ConvertExtension).ToList();

            foreach (X509Extension ext in exts2)
            {
                _extensions.Add(ext);
            }
        }
Exemplo n.º 2
0
 void InitializeCom(IX509CertificateTemplate template)
 {
     if (CryptographyUtils.TestOleCompat())
     {
         if (((Int32)template.Property[EnrollmentTemplateProperty.TemplatePropPrivateKeyFlags] & (Int32)PrivateKeyFlags.RequireKeyArchival) > 0)
         {
             KeyArchival = true;
             try {
                 IObjectId soid = (IObjectId)template.Property[EnrollmentTemplateProperty.TemplatePropSymmetricAlgorithm];
                 EncryptionAlgorithm = new Oid(soid.Value);
             } catch { }
             try {
                 KeyLength = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropSymmetricKeyLength];
             } catch { }
         }
     }
     else
     {
         if (((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropPrivateKeyFlags] & (Int32)PrivateKeyFlags.RequireKeyArchival) > 0)
         {
             KeyArchival = true;
             try {
                 IObjectId soid = (IObjectId)template.Property[EnrollmentTemplateProperty.TemplatePropSymmetricAlgorithm];
                 EncryptionAlgorithm = new Oid(soid.Value);
             } catch { }
             try {
                 KeyLength = Convert.ToInt32(template.Property[EnrollmentTemplateProperty.TemplatePropSymmetricKeyLength]);
             } catch { }
         }
     }
 }
Exemplo n.º 3
0
 void initializeCom(IX509CertificateTemplate template)
 {
     Name        = (String)template.Property[EnrollmentTemplateProperty.TemplatePropCommonName];
     DisplayName = (String)template.Property[EnrollmentTemplateProperty.TemplatePropFriendlyName];
     OID         = new Oid(((IObjectId)template.Property[EnrollmentTemplateProperty.TemplatePropOID]).Value);
     if (CryptographyUtils.TestOleCompat())
     {
         major         = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropMajorRevision];
         minor         = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropMinorRevision];
         SchemaVersion = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropSchemaVersion];
     }
     else
     {
         major         = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropMajorRevision]);
         minor         = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropMinorRevision]);
         SchemaVersion = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropSchemaVersion]);
     }
 }
Exemplo n.º 4
0
 void InitializeCom(IX509CertificateTemplate template)
 {
     if (CryptographyUtils.TestOleCompat())
     {
         try {
             pkf = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropPrivateKeyFlags];
         } catch { }
         MinimalKeyLength = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropMinimumKeySize];
         KeySpec          = (X509KeySpecFlags)(Int32)template.Property[EnrollmentTemplateProperty.TemplatePropKeySpec];
         try {
             CNGKeyUsage = (X509CNGKeyUsages)(Int32)template.Property[EnrollmentTemplateProperty.TemplatePropKeyUsage];
         } catch { }
     }
     else
     {
         try {
             pkf = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropPrivateKeyFlags]);
         } catch { }
         MinimalKeyLength = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropMinimumKeySize]);
         KeySpec          = (X509KeySpecFlags)Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropKeySpec]);
         try {
             CNGKeyUsage = (X509CNGKeyUsages)Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropKeyUsage]);
         } catch { }
     }
     try {
         CSPList = (String[])template.Property[EnrollmentTemplateProperty.TemplatePropCryptoProviders];
     } catch { }
     try {
         KeyAlgorithm = new Oid((String)template.Property[EnrollmentTemplateProperty.TemplatePropAsymmetricAlgorithm]);
     } catch {
         KeyAlgorithm = new Oid("RSA");
     }
     try {
         HashAlgorithm = new Oid((String)template.Property[EnrollmentTemplateProperty.TemplatePropHashAlgorithm]);
     } catch {
         HashAlgorithm = new Oid("SHA1");
     }
     try {
         PrivateKeySecuritySDDL = (String)template.Property[EnrollmentTemplateProperty.TemplatePropKeySecurityDescriptor];
     } catch { }
 }
Exemplo n.º 5
0
 void InitializeCom(IX509CertificateTemplate template)
 {
     if (CryptographyUtils.TestOleCompat())
     {
         try {
             SignatureCount  = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropRASignatureCount];
             enrollmentFlags = (Int32)template.Property[EnrollmentTemplateProperty.TemplatePropEnrollmentFlags];
         } catch {
             SignatureCount  = 0;
             enrollmentFlags = 0;
         }
     }
     else
     {
         try {
             SignatureCount  = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropRASignatureCount]);
             enrollmentFlags = Convert.ToInt32((UInt32)template.Property[EnrollmentTemplateProperty.TemplatePropEnrollmentFlags]);
         } catch {
             SignatureCount  = 0;
             enrollmentFlags = 0;
         }
     }
     if (SignatureCount > 0)
     {
         try {
             IObjectIds oids = (IObjectIds)template.Property[EnrollmentTemplateProperty.TemplatePropRAEKUs];
             ApplicationPolicy = new Oid(oids[0].Value);
         } catch { }
         try {
             OidCollection raoids = new OidCollection();
             IObjectIds    oids   = (IObjectIds)template.Property[EnrollmentTemplateProperty.TemplatePropRACertificatePolicies];
             foreach (IObjectId rapoid in oids)
             {
                 raoids.Add(new Oid(rapoid.Value));
             }
             CertificatePolicies = raoids;
         } catch { }
     }
 }