3using System.Security.Cryptography.X509Certificates;
5using System.Threading.Tasks;
19 public const string ContentType =
"application/pem-certificate-chain";
33 private static readonly
string[] contentTypes =
new string[] {
ContentType };
71 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
73 List<X509Certificate2> Certificates =
new List<X509Certificate2>();
74 string s = Encoding.ASCII.GetString(Data);
77 while ((i = s.IndexOf(
"-----BEGIN CERTIFICATE-----")) >= 0)
79 s = s.Substring(i + 27).TrimStart();
81 i = s.IndexOf(
"-----END CERTIFICATE-----");
84 byte[] Bin = Convert.FromBase64String(s.Substring(0, i).TrimEnd());
85 s = s.Substring(i + 25).TrimStart();
87 X509Certificate2 Certificate =
new X509Certificate2(Bin);
89 Certificates.Add(Certificate);
104 if (
string.Compare(FileExtension,
"pem",
true) == 0)
127 FileExtension =
"pem";
131 FileExtension =
string.Empty;
Contains information about a response to a content request.
Decodes certificates encoded using the application/pem-certificate-chain content type.
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
string[] ContentTypes
Supported content types.
string[] FileExtensions
Supported file extensions.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
const string ContentType
application/pem-certificate-chain
PemDecoder()
Decodes certificates encoded using the application/pem-certificate-chain content type.
Interface for reporting progress about an encoding or decoding.
Basic interface for Internet Content decoders. A class implementing this interface and having a defau...