Repository: dotnet/runtime
File: src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePolicy.cs (C#)

Code before:
        }

        private static int ReadInhibitAnyPolicyExtension(byte[] rawData)
        {
            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.DER);
            int inhibitAnyPolicy;
            reader.TryReadInt32(out inhibitAnyPolicy);
            reader.ThrowIfNotEmpty();
            return inhibitAnyPolicy;
        }

        private static void ReadCertPolicyConstraintsExtension(byte[] rawData, CertificatePolicy policy)
        {
            PolicyConstraintsAsn constraints = PolicyConstraintsAsn.Decode(
                rawData,
                AsnEncodingRules.DER);

            policy.RequireExplicitPolicyDepth = constraints.RequireExplicitPolicyDepth;
            policy.InhibitMappingDepth = constraints.InhibitMappingDepth;
        }

        private static ISet<string> ReadExtendedKeyUsageExtension(byte[] rawData)
        {
            HashSet<string> oids = new HashSet<string>();

            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.BER);
            AsnReader sequenceReader = reader.ReadSequence();
            reader.ThrowIfNotEmpty();

            //OidCollection usages
            while (sequenceReader.HasData)
            {
                oids.Add(sequenceReader.ReadObjectIdentifierAsString());
            }

            return oids;
        }

        internal static ISet<string> ReadCertPolicyExtension(byte[] rawData)
        {
            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.DER);
            AsnReader sequenceReader = reader.ReadSequence();
            reader.ThrowIfNotEmpty();

            HashSet<string> policies = new HashSet<string>();
            while (sequenceReader.HasData)
            {
                PolicyInformationAsn.Decode(sequenceReader, out PolicyInformationAsn policyInformation);
                policies.Add(policyInformation.PolicyIdentifier);

                // There is an optional policy qualifier here, but it is for information

Review comment (suggestion):
This one should be DER (everything about a certificate has to be DER, so the X509Certificates library usually only ever has that one...)

Code after:
        }

        private static int ReadInhibitAnyPolicyExtension(byte[] rawData)
        {
            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.DER);
            int inhibitAnyPolicy;
            reader.TryReadInt32(out inhibitAnyPolicy);
            reader.ThrowIfNotEmpty();
            return inhibitAnyPolicy;
        }

        private static void ReadCertPolicyConstraintsExtension(byte[] rawData, CertificatePolicy policy)
        {
            PolicyConstraintsAsn constraints = PolicyConstraintsAsn.Decode(
                rawData,
                AsnEncodingRules.DER);

            policy.RequireExplicitPolicyDepth = constraints.RequireExplicitPolicyDepth;
            policy.InhibitMappingDepth = constraints.InhibitMappingDepth;
        }

        private static ISet<string> ReadExtendedKeyUsageExtension(byte[] rawData)
        {
            HashSet<string> oids = new HashSet<string>();

            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.DER);
            AsnReader sequenceReader = reader.ReadSequence();
            reader.ThrowIfNotEmpty();

            //OidCollection usages
            while (sequenceReader.HasData)
            {
                oids.Add(sequenceReader.ReadObjectIdentifierAsString());
            }

            return oids;
        }

        internal static ISet<string> ReadCertPolicyExtension(byte[] rawData)
        {
            AsnReader reader = new AsnReader(rawData, AsnEncodingRules.DER);
            AsnReader sequenceReader = reader.ReadSequence();
            reader.ThrowIfNotEmpty();

            HashSet<string> policies = new HashSet<string>();
            while (sequenceReader.HasData)
            {
                PolicyInformationAsn.Decode(sequenceReader, out PolicyInformationAsn policyInformation);
                policies.Add(policyInformation.PolicyIdentifier);

                // There is an optional policy qualifier here, but it is for information