|
|
|
@ -46,7 +46,8 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
});
|
|
|
|
|
var provider = Data.WebResource.Instance().Provider;
|
|
|
|
|
ui.AddCell("主协议", provider["scheme"] ?? "http", new UIClick("Domain").Send(request.Model, request.Command))
|
|
|
|
|
.AddCell("主域名", provider["domain"] ?? "未设置", new UIClick("Domain").Send(request.Model, request.Command)).AddCell("连接符", provider["union"] ?? ".", new UIClick("Domain").Send(request.Model, request.Command));
|
|
|
|
|
.AddCell("主域名", provider["domain"] ?? "未设置", new UIClick("Domain").Send(request.Model, request.Command));
|
|
|
|
|
// .AddCell("连接符", provider["union"] ?? ".", new UIClick("Domain").Send(request.Model, request.Command));
|
|
|
|
|
|
|
|
|
|
ui.NewSection().AddCell("日志组件", new UIClick().Send("Proxy", "LogConf"));
|
|
|
|
|
|
|
|
|
@ -168,11 +169,11 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
var union = provider["union"] ?? ".";
|
|
|
|
|
var scheme = provider["scheme"] ?? "http";
|
|
|
|
|
fm.AddRadio("主协议", "scheme").Put("http", "http", scheme == "http").Put("https", "https", scheme == "https");
|
|
|
|
|
fm.AddRadio("连接符", "union").Put("-", "-", union == "-").Put(".", ".", union == ".");
|
|
|
|
|
// fm.AddRadio("连接符", "union").Put("-", "-", union == "-").Put(".", ".", union == ".");
|
|
|
|
|
fm.Submit("确认", $"{request.Model}.{request.Command}");
|
|
|
|
|
return fm;
|
|
|
|
|
});
|
|
|
|
|
provider.Attributes["union"] = Domains["union"];
|
|
|
|
|
// provider.Attributes["union"] = Domains["union"];
|
|
|
|
|
provider.Attributes["scheme"] = Domains["scheme"];
|
|
|
|
|
provider.Attributes["domain"] = Domains["domain"];
|
|
|
|
|
|
|
|
|
@ -311,7 +312,7 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
{
|
|
|
|
|
var fm = new UIFormDialog() { Title = "申请证书" };
|
|
|
|
|
fm.AddText("域名", "Domain", String.Empty);
|
|
|
|
|
fm.AddCheckBox("", "Dcv", "default").Put("自动智能验证域名所有权", "file", true)
|
|
|
|
|
fm.AddRadio("", "Dcv").Put("自动智能验证域名所有权", "file", true)
|
|
|
|
|
.Put("CName方式验证域名所有权", "cname");
|
|
|
|
|
fm.Submit("确认申请", $"{request.Model}.{request.Command}");
|
|
|
|
|
return fm;
|
|
|
|
@ -361,6 +362,12 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
else if (string.Equals(hs["code"], "verifing"))
|
|
|
|
|
{
|
|
|
|
|
response.Redirect(request.Model, request.Command, new WebMeta("Domain", host).Put("Model", "CSR"), true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(hs["code"], "privateKey"))
|
|
|
|
|
{
|
|
|
|
|
response.Redirect(request.Model, request.Command, new WebMeta("Domain", host).Put("Model", "PrivateKey"), true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(hs["code"], "url"))
|
|
|
|
|
{
|
|
|
|
@ -460,11 +467,15 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
csr.AddCell("证书状态", hash["state"] as string);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hash.ContainsKey("expire"))
|
|
|
|
|
{
|
|
|
|
|
csr.AddCell("证书过期", hash["expire"] as string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (hash.ContainsKey("state"))
|
|
|
|
|
{
|
|
|
|
|
ui.NewSection().AddCell("证书状态", hash["state"] as string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UMC.Net.Certificater.Certificates.TryGetValue(host, out var _v))
|
|
|
|
@ -472,7 +483,7 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
if (_v.Certificate != null)
|
|
|
|
|
{
|
|
|
|
|
var cn = _v.Certificate.Subject.Split(',').First(r => r.Trim().StartsWith("CN=")).Substring(3);
|
|
|
|
|
if (hash.ContainsKey("expire"))
|
|
|
|
|
if (hash.ContainsKey("expire") && hash.ContainsKey("order"))
|
|
|
|
|
{
|
|
|
|
|
ui.NewSection().AddCell("证书公用名", cn);
|
|
|
|
|
}
|
|
|
|
@ -502,7 +513,16 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ui.NewSection().AddCell("自动续签", hash["contract"] as string, new UIClick("Model", "Recharge", "Code", hash["domain"] as string).Send(request.Model, request.Command));
|
|
|
|
|
if (hash.ContainsKey("isLock"))
|
|
|
|
|
{
|
|
|
|
|
ui.NewSection().AddCell("自动续签", hash["contract"] as string);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui.NewSection().AddCell("自动续签", hash["contract"] as string, new UIClick("Model", "Recharge", "Code", hash["domain"] as string).Send(request.Model, request.Command));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -638,6 +658,52 @@ namespace UMC.Proxy.Activities
|
|
|
|
|
this.Prompt("请输入正确的端口号");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "PrivateKey":
|
|
|
|
|
{
|
|
|
|
|
var host = this.AsyncDialog("Domain", g => this.Prompt("请输入域名"));
|
|
|
|
|
var privateKey = UIDialog.AsyncDialog(this.Context, "PrivateKey", r =>
|
|
|
|
|
{
|
|
|
|
|
var fm = new UIFormDialog() { Title = "证书私钥" };
|
|
|
|
|
fm.AddTextValue().Put("域名", host);
|
|
|
|
|
fm.AddTextarea("私钥", "PrivateKey", String.Empty).PlaceHolder("证书.key文件内容").Put("tip", "证书私钥"); ;
|
|
|
|
|
fm.Submit("确认导入", $"{request.Model}.{request.Command}");
|
|
|
|
|
return fm;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var webr2 = new Uri(APIProxy.Uri, "Certificater").WebRequest();
|
|
|
|
|
|
|
|
|
|
var rese = UMC.Proxy.Utility.Sign(webr2, WebResource.Instance().Provider["appSecret"])
|
|
|
|
|
.Post(new WebMeta().Put("type", "cert", "domain", host));
|
|
|
|
|
if (rese.StatusCode != System.Net.HttpStatusCode.OK)
|
|
|
|
|
{
|
|
|
|
|
this.Prompt("提示", rese.ReadAsString());
|
|
|
|
|
}
|
|
|
|
|
var json = rese.ReadAsString();
|
|
|
|
|
|
|
|
|
|
var cert = JSON.Deserialize<WebMeta>(json);
|
|
|
|
|
var domain = cert["domain"];
|
|
|
|
|
var publicKey = cert["publicKey"];
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var x509 = X509Certificate2.CreateFromPem(publicKey, privateKey);
|
|
|
|
|
var p = UMC.Data.Provider.Create(domain, "privateKey");
|
|
|
|
|
p.Attributes["publicKey"] = publicKey;
|
|
|
|
|
p.Attributes["privateKey"] = privateKey;
|
|
|
|
|
var certs = UMC.Data.Reflection.Configuration("certs");
|
|
|
|
|
certs.Add(p);
|
|
|
|
|
UMC.Net.Certificater.Certificates[p.Name] = new Certificater { Name = p.Name, Status = 1, Certificate = x509 };
|
|
|
|
|
UMC.Data.Reflection.Configuration("certs", certs);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.Prompt("证书错误", ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Context.Send($"{request.Model}.{request.Command}", true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
var pr = hosts[model];
|
|
|
|
|