コード例 #1
0
        public virtual void DecodeX509BasicConstraints2Extension(
            byte[] encoded,
            out bool certificateAuthority,
            out bool hasPathLengthConstraint,
            out int pathLengthConstraint)
        {
            BasicConstraintsAsn constraints = BasicConstraintsAsn.Decode(encoded, AsnEncodingRules.BER);

            certificateAuthority    = constraints.CA;
            hasPathLengthConstraint = constraints.PathLengthConstraint.HasValue;
            pathLengthConstraint    = constraints.PathLengthConstraint.GetValueOrDefault();
        }
コード例 #2
0
        public virtual byte[] EncodeX509BasicConstraints2Extension(
            bool certificateAuthority,
            bool hasPathLengthConstraint,
            int pathLengthConstraint)
        {
            BasicConstraintsAsn constraints = default;

            constraints.CA = certificateAuthority;
            if (hasPathLengthConstraint)
            {
                constraints.PathLengthConstraint = pathLengthConstraint;
            }

            AsnWriter writer = new AsnWriter(AsnEncodingRules.DER);

            constraints.Encode(writer);
            return(writer.Encode());
        }
コード例 #3
0
        public virtual byte[] EncodeX509BasicConstraints2Extension(
            bool certificateAuthority,
            bool hasPathLengthConstraint,
            int pathLengthConstraint)
        {
            BasicConstraintsAsn constraints = new BasicConstraintsAsn();

            constraints.CA = certificateAuthority;
            if (hasPathLengthConstraint)
            {
                constraints.PathLengthConstraint = pathLengthConstraint;
            }

            using (AsnWriter writer = AsnSerializer.Serialize(constraints, AsnEncodingRules.DER))
            {
                return(writer.Encode());
            }
        }