示例#1
0
 Boolean Equals(X509CRLEntry other)
 {
     return(String.Equals(SerialNumber, other.SerialNumber));
 }
示例#2
0
        void genVerboseString(StringBuilder SB, Int32 revCertEntries)
        {
            String n = Environment.NewLine;

            SB.AppendLine("X509 Certificate Revocation List:");
            SB.AppendLine($"Version: {Version}");
            SB.AppendLine("Issuer: ");
            String[] tokens = Issuer.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (Int32 index = 0; index < tokens.Length; index++)
            {
                tokens[index] = "    " + tokens[index].Trim();
            }
            SB.AppendLine(String.Join(n, tokens));
            SB.AppendLine();
            SB.AppendLine($"This Update: {ThisUpdate}");
            SB.AppendLine(NextUpdate == null
                ? "Next Update: Infinity"
                : $"Next Update: {NextUpdate}");
            SB.AppendLine();
            SB.AppendLine($"CRL Entries: {_revokedCerts.Count}");
            if (_revokedCerts.Count > 0)
            {
                Int32 upperBound     = _revokedCerts.Count;
                Int32 truncatedCount = 0;
                if (revCertEntries > 0)
                {
                    truncatedCount = _revokedCerts.Count - revCertEntries;
                    upperBound     = Math.Min(revCertEntries, _revokedCerts.Count);
                }

                for (Int32 index = 0; index < upperBound; index++)
                {
                    X509CRLEntry revCert = _revokedCerts[index];
                    SB.AppendLine($"    Serial Number: {revCert.SerialNumber}");
                    SB.AppendLine($"    Revocation Date: {revCert.RevocationDate}");
                    if (revCert.ReasonCode != 0)
                    {
                        SB.AppendLine($"    Revocation Reason: {revCert.ReasonMessage} ({revCert.ReasonCode})");
                    }

                    SB.AppendLine();
                }

                if (truncatedCount > 0)
                {
                    SB.AppendLine("    <...>");
                    SB.AppendLine($"    Next {truncatedCount} entries are truncated from dump.");
                }
            }

            SB.AppendLine($"CRL Extensions: {_extensions.Count}");
            if (_extensions.Count > 0)
            {
                foreach (X509Extension ext in _extensions)
                {
                    SB.Append($"  OID={ext.Oid.Format(true)}, ");
                    SB.AppendLine($"Critical={ext.Critical}, Length={ext.RawData.Length} ({ext.RawData.Length:x2}):");
                    SB.AppendLine($"    {ext.Format(true).Replace(n, $"{n}    ").TrimEnd()}");
                    SB.AppendLine();
                }
            }
            SB.AppendLine("Signature Algorithm:");
            SB.AppendLine($"    Algorithm ObjectId: {SignatureAlgorithm.Format(true)}");
            SB.Append($"Signature: Unused bits={sigUnused}{n}    ");
            String tempString = AsnFormatter.BinaryToString(signature, EncodingType.HexAddress);

            SB.Append($"{tempString.Replace(n, $"{n}    ").TrimEnd()}");
        }