Code
·
50 lines
·
1552 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50/*
https://www.rfc-editor.org/rfc/rfc4398.html
The CERT Resource Record
The CERT resource record (RR) has the structure given below. Its RR
type code is 37.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type | key tag |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| algorithm | /
+---------------+ certificate or CRL /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
*/
using MailSharp.DNS.Records;
namespace MailSharp.DNS.Records;
public record RecordCERT : DnsRecord
{
public ushort CertType { get; init; } // 1=PKIX, 2=SPKI, 3=PGP, 4=IPKIX, etc.
public ushort KeyTag { get; init; }
public byte Algorithm { get; init; }
public string Certificate { get; init; } = string.Empty; // altijd Base64
public RecordCERT(RecordReader rr) : base(rr)
{
ushort rdLength = rr.ReadUInt16(-2);
CertType = rr.ReadUInt16();
KeyTag = rr.ReadUInt16();
Algorithm = rr.ReadByte();
byte[] certData = rr.ReadBytes(rdLength - rr.Position);
Certificate = certData.Length == 0
? "."
: Convert.ToBase64String(certData);
}
public override string ToString()
{
return $"{CertType} {KeyTag} {Algorithm} {Certificate}";
}
}