Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AcmeChallenge.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
5
7{
12 {
16 pending,
17
21 processing,
22
26 valid,
27
31 invalid
32 }
33
38 {
39 private readonly AcmeChallengeStatus status;
40 private readonly string type;
41 private readonly string token;
42 private readonly DateTime? validated;
43
44 internal AcmeChallenge(AcmeClient Client, Uri AccountLocation, IEnumerable<KeyValuePair<string, object>> Obj)
45 : base(Client, AccountLocation, null)
46 {
47 foreach (KeyValuePair<string, object> P in Obj)
48 {
49 switch (P.Key)
50 {
51 case "status":
52 if (!Enum.TryParse(P.Value as string, out this.status))
53 throw new ArgumentException("Invalid ACME challenge status: " + P.Value.ToString(), "status");
54 break;
55
56 case "validated":
57 if (XML.TryParse(P.Value as string, out DateTime TP))
58 this.validated = TP;
59 else
60 throw new ArgumentException("Invalid date and time value.", "validated");
61 break;
62
63 case "url":
64 this.Location = new Uri(P.Value as string);
65 break;
66
67 case "type":
68 this.type = P.Value as string;
69 break;
70
71 case "token":
72 this.token = P.Value as string;
73 break;
74 }
75 }
76 }
77
81 public AcmeChallengeStatus Status => this.status;
82
86 public DateTime? Validated => this.validated;
87
91 public string Type => this.type;
92
96 public string Token => this.token;
97
101 public virtual string KeyAuthorization
102 {
103 get
104 {
105 return this.token + "." + this.Client.JwkThumbprint;
106 }
107 }
108
113 public Task<AcmeChallenge> AcknowledgeChallenge()
114 {
115 return this.Client.AcknowledgeChallenge(this.AccountLocation, this.Location);
116 }
117 }
118}
Helps with common XML-related tasks.
Definition: XML.cs:19
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:744
Base class of all ACME challenges.
DateTime? Validated
When the challenge was validated.
AcmeChallengeStatus Status
The status of this challenge.
Task< AcmeChallenge > AcknowledgeChallenge()
Acknowledges the challenge.
virtual string KeyAuthorization
Key authorization string. Used as response to challenge.
string Type
Type of challenge.
Implements an ACME client for the generation of certificates using ACME-compliant certificate servers...
Definition: AcmeClient.cs:24
async Task< AcmeChallenge > AcknowledgeChallenge(Uri AccountLocation, Uri ChallengeLocation)
Acknowledges a challenge from the server.
Definition: AcmeClient.cs:639
AcmeClient Client
ACME client.
Definition: AcmeObject.cs:26
Abstract base class for all ACME resources.
Definition: AcmeResource.cs:11
Uri Location
Location of resource.
Definition: AcmeResource.cs:37
Uri AccountLocation
Account location.
Definition: AcmeResource.cs:31
AcmeChallengeStatus
ACME Challenge status enumeration