提交 ae728423 编写于 作者: W wq1234wq

证书

上级 eba04b97
...@@ -57,8 +57,6 @@ e ...@@ -57,8 +57,6 @@ e
.subscribe( .subscribe(
{ {
next: next => { next: next => {
if(next.code===10000){
let url = window.URL.createObjectURL(next); let url = window.URL.createObjectURL(next);
let a = document.createElement('a'); let a = document.createElement('a');
document.body.appendChild(a); document.body.appendChild(a);
...@@ -68,15 +66,11 @@ e ...@@ -68,15 +66,11 @@ e
a.click(); a.click();
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
a.remove(); a.remove();
}else{
this.msg.create('error', '证书下载失败:'+next.msg);
}
}, },
error: error => { error: error => {
this.msg.create('error', '证书下载失败:'+error.error); this.msg.create('error', '证书下载失败:' + error.error);
}, complete: () => { } }, complete: () => { }
} }
); );
......
...@@ -250,7 +250,15 @@ namespace IoTSharp.Controllers ...@@ -250,7 +250,15 @@ namespace IoTSharp.Controllers
SubjectAlternativeNameBuilder altNames = new SubjectAlternativeNameBuilder(); SubjectAlternativeNameBuilder altNames = new SubjectAlternativeNameBuilder();
altNames.AddUserPrincipalName(did.Device.Id.ToString()); altNames.AddUserPrincipalName(did.Device.Id.ToString());
if (!string.IsNullOrEmpty(_setting.MqttBroker.DomainName))
{
altNames.AddDnsName(_setting.MqttBroker.DomainName); altNames.AddDnsName(_setting.MqttBroker.DomainName);
if (!string.IsNullOrEmpty(_setting.MqttBroker.ServerIPAddress))
{
if (_setting.MqttBroker.TlsPort > 0 && _setting.MqttBroker.TlsPort < 65535)
{
altNames.AddUri(new Uri($"mqtt://{_setting.MqttBroker.ServerIPAddress}:{_setting.MqttBroker.TlsPort}")); altNames.AddUri(new Uri($"mqtt://{_setting.MqttBroker.ServerIPAddress}:{_setting.MqttBroker.TlsPort}"));
string name = $"CN={dev.Name},C=CN,L={dev.Customer.Province ?? "IoTSharp"},ST={dev.Customer.City ?? "IoTSharp"},O={dev.Customer.Name},OU={dev.Tenant.Name}"; string name = $"CN={dev.Name},C=CN,L={dev.Customer.Province ?? "IoTSharp"},ST={dev.Customer.City ?? "IoTSharp"},O={dev.Customer.Name},OU={dev.Tenant.Name}";
var tlsclient = option.CACertificate.CreateTlsClientRSA(name, altNames); var tlsclient = option.CACertificate.CreateTlsClientRSA(name, altNames);
...@@ -268,11 +276,23 @@ namespace IoTSharp.Controllers ...@@ -268,11 +276,23 @@ namespace IoTSharp.Controllers
return new ApiResult<DeviceIdentity>(ApiCode.Success, "OK", new DeviceIdentity() { Id = did.Id, IdentityType = did.IdentityType, IdentityId = did.IdentityId }); return new ApiResult<DeviceIdentity>(ApiCode.Success, "OK", new DeviceIdentity() { Id = did.Id, IdentityType = did.IdentityType, IdentityId = did.IdentityId });
} }
else else
{
return new ApiResult<DeviceIdentity>(ApiCode.NotFoundDeviceIdentity, "Please set valid MqttBroker TlsPort", null);
}
}
return new ApiResult<DeviceIdentity>(ApiCode.NotFoundDeviceIdentity, "Please set MqttBroker ServerIPAddress", null);
}
return new ApiResult<DeviceIdentity>(ApiCode.NotFoundDeviceIdentity, "Please set MqttBroker domain name", null);
}
else
{ {
return new ApiResult<DeviceIdentity>(ApiCode.NotFoundDeviceIdentity, "Not found device identity", null); return new ApiResult<DeviceIdentity>(ApiCode.NotFoundDeviceIdentity, "Not found device identity", null);
} }
} }
/// <summary> /// <summary>
/// 下载证书 /// 下载证书
/// </summary> /// </summary>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
}, },
"DataBase": "MySql", "DataBase": "MySql",
"ConnectionStrings": { "ConnectionStrings": {
"IoTSharp": "server=localhost;user=root;password=kissmedatabase=IoTSharp", "IoTSharp": "server=localhost;user=root;password=kissme;database=IoTSharp",
"TelemetryStorage": "server=localhost;user=root;password=kissme;database=IoTSharp" "TelemetryStorage": "server=localhost;user=root;password=kissme;database=IoTSharp"
}, },
"JwtKey": "kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme", "JwtKey": "kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册