Наследование: Org.BouncyCastle.Asn1.Asn1Encodable
        public X509Certificate(
			X509CertificateStructure c)
        {
            this.c = c;

            try
            {
                Asn1OctetString str = this.GetExtensionValue(new DerObjectIdentifier("2.5.29.19"));

                if (str != null)
                {
                    basicConstraints = BasicConstraints.GetInstance(
                        X509ExtensionUtilities.FromExtensionValue(str));
                }
            }
            catch (Exception e)
            {
                throw new CertificateParsingException("cannot construct BasicConstraints: " + e);
            }

            try
            {
                Asn1OctetString str = this.GetExtensionValue(new DerObjectIdentifier("2.5.29.15"));

                if (str != null)
                {
                    DerBitString bits = DerBitString.GetInstance(
                        X509ExtensionUtilities.FromExtensionValue(str));

                    byte[] bytes = bits.GetBytes();
                    int length = (bytes.Length * 8) - bits.PadBits;

                    keyUsage = new bool[(length < 9) ? 9 : length];

                    for (int i = 0; i != length; i++)
                    {
            //						keyUsage[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
                        keyUsage[i] = (bytes[i / 8] & (0x80 >> (i % 8))) != 0;
                    }
                }
                else
                {
                    keyUsage = null;
                }
            }
            catch (Exception e)
            {
                throw new CertificateParsingException("cannot construct KeyUsage: " + e);
            }
        }
Пример #2
0
 public static BasicConstraints GetInstance(Asn1TaggedObject obj, bool explicitly)
 {
     return(BasicConstraints.GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Пример #3
0
 /// <summary>
 /// Initializes BasicConstraints from a <see cref="Org.BouncyCastle.Asn1.X509.BasicConstraints"/>
 /// </summary>
 /// <param name="basicContraints"><see cref="Org.BouncyCastle.Asn1.X509.BasicConstraints"/></param>
 public BasicConstraints(Org.BouncyCastle.Asn1.X509.BasicConstraints basicContraints)
 {
     this.X509BasicContraints = basicContraints;
 }
 public void AddBasicContraintsOid(bool isCA, int pathLenConstraint)
 {
     BasicConstraints constraints = new BasicConstraints(pathLenConstraint);
     generator.AddExtension(X509Extensions.BasicConstraints, true, constraints);
 }