修复Linux签名验签失败的问题

This commit is contained in:
ChenYi 2025-11-03 16:10:58 +08:00
parent a9e34a5546
commit a453fb96b1
4 changed files with 101 additions and 91 deletions

View File

@ -3,71 +3,68 @@
"SelfUrl": "http://localhost:44315", "SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.70.11:4200,http://47.110.53.196:30711,http://192.168.111.174:30711" "CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://10.10.70.11:4200,http://47.110.53.196:30711,http://192.168.111.174:30711"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=mysql;Port=3306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;" "Default": "Data Source=mysql;Port=3306;Database=JiSheIoTProDB;uid=root;pwd=JiShe!aqG#5kGgh&0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true;"
// // },
// "PrepayDB": "server=rm-m5el3d1u1k0wzk70n2o.sqlserver.rds.aliyuncs.com,3433;database=jishe.sysdb;uid=v3sa;pwd=JiShe123;Encrypt=False;Trust Server Certificate=False", "Hangfire": {
// "EnergyDB": "server=rm-wz9hw529i3j1e3b5fbo.sqlserver.rds.aliyuncs.com,3433;database=db_energy;uid=yjdb;pwd=Kdjdhf+9*7ad222LL;Encrypt=False;Trust Server Certificate=False"
},
"Hangfire": {
"Redis": {
"Host": "redis:6379,password=1q3J@BGf!yhTaD46nS#",
"DB": "2"
}
},
"Redis": { "Redis": {
"Configuration": "redis:6379,defaultdatabase=5,password=1q3J@BGf!yhTaD46nS#" "Host": "redis:6379,password=1q3J@BGf!yhTaD46nS#",
}, "DB": "2"
"Kafka": { }
"BootstrapServers": "47.110.62.104:9094,47.110.53.196:9094,47.110.60.222:9094", },
"EnableFilter": true, "Redis": {
"EnableAuthorization": false, "Configuration": "redis:6379,defaultdatabase=5,password=1q3J@BGf!yhTaD46nS#"
"SaslUserName": "lixiao", },
"SaslPassword": "lixiao@1980", "Kafka": {
"KafkaReplicationFactor": 3, "BootstrapServers": "47.110.62.104:9094,47.110.53.196:9094,47.110.60.222:9094",
"NumPartitions": 30, "EnableFilter": true,
"TaskThreadCount": -1 "EnableAuthorization": false,
}, "SaslUserName": "lixiao",
"Pulsar": { "SaslPassword": "lixiao@1980",
"ServiceUrl": "pulsar://pulsar-broker:9093", "KafkaReplicationFactor": 3,
"WebUrl": "http://pulsar-broker:9094", "NumPartitions": 30,
"UserName": "admin", "TaskThreadCount": -1
"TenantName": "1YMVZZkAkRArjxSD8457", },
"Namespace": "OneNET", "Pulsar": {
"PulsarSecretKey": "0fd7afb8b0d04e6abc4fdfdac2190a79", "ServiceUrl": "pulsar://pulsar-broker:9093",
"PulsarSubscriptionCustomName": "sub", "WebUrl": "http://pulsar-broker:9094",
"EnableTls": false, "UserName": "admin",
"ValidateServerCertificate": false, "TenantName": "1YMVZZkAkRArjxSD8457",
"ConnectionTimeout": 30, "Namespace": "OneNET",
"OperationTimeout": 30, "PulsarSecretKey": "0fd7afb8b0d04e6abc4fdfdac2190a79",
"KeepAliveInterval": 30, "PulsarSubscriptionCustomName": "sub",
"TaskThreadCount": 1, "EnableTls": false,
"IsSubscriber": true, "ValidateServerCertificate": false,
"DefaultPartitions": 16, "ConnectionTimeout": 30,
"DefaultBundles": 16, "OperationTimeout": 30,
"EnableAutoCreation": true, //Topic "KeepAliveInterval": 30,
"TopicMode": "Static", //Dynamic "TaskThreadCount": 1,
"EnableTopicTypeFilter": true, //Topic "IsSubscriber": true,
"AllowedTopicTypes": [ "Static" ], //Topic "DefaultPartitions": 16,
"AllowedClusters": [ "pulsar-cluster-1" ], // "DefaultBundles": 16,
"AdminRoles": [ "admin" ], "EnableAutoCreation": true, //Topic
"EnableConsumerIdleCleanup": true, "TopicMode": "Static", //Dynamic
"ConsumerIdleCleanupMinutes": 120, "EnableTopicTypeFilter": true, //Topic
"EnableProducerIdleCleanup": true, "AllowedTopicTypes": [ "Static" ], //Topic
"ProducerIdleCleanupMinutes": 60 "AllowedClusters": [ "pulsar-cluster-1" ], //
}, "AdminRoles": [ "admin" ],
"IoTDBOptions": { "EnableConsumerIdleCleanup": true,
"UserName": "root", "ConsumerIdleCleanupMinutes": 120,
"Password": "Lixiao@1980", "EnableProducerIdleCleanup": true,
"TreeModelClusterList": [ "iotdb-standalone:6667" ], "ProducerIdleCleanupMinutes": 60
"TableModelClusterList": [ "iotdb-standalone:6667" ], },
"PoolSize": 32, "IoTDBOptions": {
"DataBaseName": "jisheiotdata", "UserName": "root",
"OpenDebugMode": true, "Password": "Lixiao@1980",
"UseTableSessionPoolByDefault": false "TreeModelClusterList": [ "iotdb-standalone:6667" ],
}, "TableModelClusterList": [ "iotdb-standalone:6667" ],
"PoolSize": 32,
"DataBaseName": "jisheiotdata",
"OpenDebugMode": true,
"UseTableSessionPoolByDefault": false
},
"ServerApplicationOptions": { "ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus01", "ServerTagName": "JiSheCollectBus12",
"FirstCollectionTime": "2025-04-28 15:07:00", "FirstCollectionTime": "2025-04-28 15:07:00",
"AutomaticVerificationTime": "16:07:00", "AutomaticVerificationTime": "16:07:00",
"AutomaticTerminalVersionTime": "17:07:00", "AutomaticTerminalVersionTime": "17:07:00",
@ -75,28 +72,29 @@
"AutomaticDayFreezeTime": "02:30:00", "AutomaticDayFreezeTime": "02:30:00",
"AutomaticMonthFreezeTime": "03:30:00", "AutomaticMonthFreezeTime": "03:30:00",
"DefaultProtocolPlugin": "T37612012ProtocolPlugin", "DefaultProtocolPlugin": "T37612012ProtocolPlugin",
"VerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh", "SignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh",
"AesSecurityKey": "RPTEIGCA1KvDEXS1",
"IsAesEncrypted": false, "IsAesEncrypted": false,
"DistributedMessage": 2, "DistributedMessage": 2,
"SnowflakeWorkerId": 1 "SnowflakeWorkerId": 1
}, },
"Jwt": { "Jwt": {
"Audience": "JiShe.IoT", "Audience": "JiShe.IoT",
"SecurityKey": "dzehzRz9a8asdfaf43ghVD@d#fasdfaf567sdadfasdf=", "SecurityKey": "dzehzRz9a8asdfaf43ghVD@d#fasdfaf567sdadfasdf=",
"Issuer": "JiShe.IoT", "Issuer": "JiShe.IoT",
"ExpirationTime": 2 "ExpirationTime": 2
}, },
"FreeRedisOptions": { "FreeRedisOptions": {
"ConnectionString": "redis:6379,password=1q3J@BGf!yhTaD46nS#,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=500,defaultdatabase=14", "ConnectionString": "redis:6379,password=1q3J@BGf!yhTaD46nS#,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=500,defaultdatabase=14",
"UseDistributedCache": true "UseDistributedCache": true
}, },
"FreeSqlProviderOptions": { "FreeSqlProviderOptions": {
"UsePrepayDB": false, "UsePrepayDB": false,
"UseEnergyDB": false, "UseEnergyDB": false,
"PrintLog": false "PrintLog": false
}, },
"OneNETSecureReceiveOptions": { "OneNETSecureReceiveOptions": {
"OneNETVerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh", "OneNETVerifySignatureToken": "SIcPQnpMgaFDmNlIjNmzq5smshz7cKrh",
"OneNETAesKey": "RPTEIGCA1KvDEXS1" "OneNETAesKey": "RPTEIGCA1KvDEXS1"
} }
} }

View File

@ -56,6 +56,11 @@ namespace JiShe.IoT
{ {
configuration.GetSection(nameof(DataChannelOptions)).Bind(options); configuration.GetSection(nameof(DataChannelOptions)).Bind(options);
}); });
Configure<ServerApplicationOptions>(options =>
{
configuration.GetSection(nameof(ServerApplicationOptions)).Bind(options);
});
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

View File

@ -1,3 +1,6 @@
using JiShe.ServicePro.Core;
using Microsoft.Extensions.Configuration;
namespace JiShe.IoT; namespace JiShe.IoT;
public class Program public class Program
@ -19,12 +22,16 @@ public class Program
}) })
.ConfigureAppConfiguration((context, builder) => .ConfigureAppConfiguration((context, builder) =>
{ {
var env = context.HostingEnvironment.EnvironmentName; var env = context.HostingEnvironment.EnvironmentName;
string[] filePathArray = new string[] { System.AppDomain.CurrentDomain.BaseDirectory, "configs" }; string[] filePathArray = new string[] { System.AppDomain.CurrentDomain.BaseDirectory, "configs"};
string jsonPath = Path.Combine(filePathArray); string jsonPath = Path.Combine(filePathArray);
Log.Warning($"当前环境 {env},配置文件路径:{jsonPath}");
builder.AddJsonFile(Path.Combine(jsonPath, "appsettings.json"), false, true); string defaultJson = Path.Combine(new string[] { jsonPath, "appsettings.json" });
builder.AddJsonFile(Path.Combine(jsonPath, $"appsettings.{env}.json"), false, true); var environmentJson = Path.Combine(new string[] { jsonPath, $"appsettings.{env}.json" } );
builder.AddJsonFile(defaultJson, false, true);
builder.AddJsonFile(environmentJson, false, true);
Console.WriteLine($"当前环境 {env},配置文件路径:{environmentJson}");
}); });
await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>(); await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>();
@ -33,7 +40,7 @@ public class Program
options.Limits.MaxRequestBodySize = 100 * 1024 * 1024; // 100MB null不受限制 options.Limits.MaxRequestBodySize = 100 * 1024 * 1024; // 100MB null不受限制
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2); options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(1); options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(1);
//获取或设置请求正文的最小数据速率(字节/秒。将此属性设置为NULL表示不应强制执行最小数据速率。////获取或设置请求正文的最小数据速率(字节/秒。将此属性设置为NULL表示不应强制执行最小数据速率。 //获取或设置请求正文的最小数据速率(字节/秒。将此属性设置为NULL表示不应强制执行最小数据速率。////获取或设置请求正文的最小数据速率(字节/秒。将此属性设置为NULL表示不应强制执行最小数据速率。
options.Limits.MinRequestBodyDataRate = null;//new MinDataRate(bytesPerSecond: 2048, gracePeriod: TimeSpan.FromSeconds(10)); options.Limits.MinRequestBodyDataRate = null;//new MinDataRate(bytesPerSecond: 2048, gracePeriod: TimeSpan.FromSeconds(10));

View File

@ -85,7 +85,7 @@ namespace JiShe.IoT
/// <returns></returns> /// <returns></returns>
protected HttpDataResult<T> HandleOpenApiRequest<T>(OpenApiRequest input, ServerApplicationOptions serverOptions) where T : class protected HttpDataResult<T> HandleOpenApiRequest<T>(OpenApiRequest input, ServerApplicationOptions serverOptions) where T : class
{ {
if (input == null || serverOptions == null || string.IsNullOrWhiteSpace(input.Message) || string.IsNullOrWhiteSpace(input.Nonce) || string.IsNullOrWhiteSpace(input.Signature)) if (input == null || serverOptions == null || string.IsNullOrWhiteSpace(input.Message) || string.IsNullOrWhiteSpace(input.Nonce) || string.IsNullOrWhiteSpace(input.Signature) || serverOptions == null || string.IsNullOrWhiteSpace(serverOptions.SignatureToken))
{ {
return HttpDataResultExtensions.Failed<T>(null, "请求参数不能为空", -1101); return HttpDataResultExtensions.Failed<T>(null, "请求参数不能为空", -1101);
} }