Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SubjectAlternativeNameBuilder.cs
Go to the documentation of this file.
4using System.Net;
6using System.Text;
7
9
11{
12 private static readonly IdnMapping s_idnMapping = new IdnMapping();
13
14 private readonly List<byte[]> _encodedNames = new List<byte[]>();
15
16 public void AddEmailAddress(string emailAddress)
17 {
18 if (string.IsNullOrEmpty(emailAddress))
19 {
21 }
23 {
24 Rfc822Name = emailAddress
25 });
26 }
27
28 public void AddDnsName(string dnsName)
29 {
30 if (string.IsNullOrEmpty(dnsName))
31 {
33 }
35 {
36 DnsName = s_idnMapping.GetAscii(dnsName)
37 });
38 }
39
40 public void AddUri(Uri uri)
41 {
42 if (uri == null)
43 {
44 throw new ArgumentNullException("uri");
45 }
47 {
48 Uri = uri.AbsoluteUri.ToString()
49 });
50 }
51
53 {
54 if (ipAddress == null)
55 {
56 throw new ArgumentNullException("ipAddress");
57 }
59 {
60 IPAddress = ipAddress.GetAddressBytes()
61 });
62 }
63
64 public void AddUserPrincipalName(string upn)
65 {
66 if (string.IsNullOrEmpty(upn))
67 {
69 }
71 asnWriter.WriteCharacterString(UniversalTagNumber.UTF8String, upn);
72 byte[] array = asnWriter.Encode();
74 otherNameAsn.TypeId = "1.3.6.1.4.1.311.20.2.3";
75 otherNameAsn.Value = array;
78 {
79 OtherName = value
80 });
81 }
82
83 public X509Extension Build(bool critical = false)
84 {
86 using (asnWriter.PushSequence())
87 {
88 foreach (byte[] encodedName in _encodedNames)
89 {
90 asnWriter.WriteEncodedValue(encodedName);
91 }
92 }
93 return new X509Extension("2.5.29.17", asnWriter.Encode(), critical);
94 }
95
97 {
98 try
99 {
101 generalName.Encode(asnWriter);
102 _encodedNames.Add(asnWriter.Encode());
103 }
105 {
107 }
108 }
109}
static string Cryptography_Invalid_IA5String
Definition SR.cs:120
static string Arg_EmptyOrNullString
Definition SR.cs:16
Definition SR.cs:7
string AbsoluteUri
Definition Uri.cs:266