private async void btnComplete_Click(object sender, EventArgs e) { string sURL = this.txtChallenge.Text; bool onceMessage = false; if (!string.IsNullOrEmpty(sURL)) { while (true) { var wrGETURL = WebRequest.Create(sURL + "/index.html") as HttpWebRequest; //WebProxy myProxy = new WebProxy("myproxy", 80); //myProxy.BypassProxyOnLocal = true; //wrGETURL.Proxy = myProxy; wrGETURL.Proxy = WebRequest.GetSystemWebProxy(); HttpWebResponse response; try { response = wrGETURL.GetResponse() as HttpWebResponse; } catch (WebException ex) { response = ex.Response as HttpWebResponse; } if (response.StatusCode == HttpStatusCode.OK) { using (Stream objStream = response.GetResponseStream()) { var objReader = new StreamReader(objStream); var str = objReader.ReadToEnd(); if (str == this.txtKey.Text) { break; } } } await Task.Delay(1000); if (!onceMessage) { this.listBox1.Items.Add("Waiting for file to be uploaded."); } onceMessage = true; } } var idref = Registrator.GetIdentifier(this.txtDomain.Text); var state = new UpdateIdentifier { IdentifierRef = idref }.GetValue <AuthorizationState>(); if (state.Status != "valid") { state = new SubmitChallenge { IdentifierRef = idref, ChallengeType = "http-01" }.GetValue <AuthorizationState>(); int countPending = 0; while (state.Status == "pending") { this.listBox1.Items.Add("Status is still 'pending', waiting for it to change..."); await Task.Delay((countPending + 1) * 1000); state = new UpdateIdentifier { IdentifierRef = idref }.GetValue <AuthorizationState>(); countPending++; } } if (state.Status == "valid") { var certificateInfo = new GetCertificate { CertificateRef = "cert1" }.GetValue <CertificateInfo>(); if (certificateInfo == null) { new NewCertificate { IdentifierRef = idref, Alias = "cert1", Generate = SwitchParameter.Present } }