This commit is contained in:
mmrbnjd
2024-04-05 17:43:11 +03:30
parent 4eb04aef14
commit c439f88650
7 changed files with 175 additions and 52 deletions

View File

@@ -42,7 +42,7 @@ namespace Back.Controllers
{
var resultValidationmodel = await _mobilevalidation.ValidateAsync(model.Mobile);
if (!resultValidationmodel.IsValid)
return BadRequest(resultValidationmodel.Errors);
return BadRequest(resultValidationmodel.Errors.Select(s=>s.ErrorMessage ).ToList());
return Ok(await _sBase.CreateCsrAndPrivateKey(model));
}
[HttpPost("ReadPublicKeyFromCER")]

View File

@@ -99,14 +99,12 @@ namespace Back.Services
string csr = Encoding.UTF8.GetString(buffer);
stream.Flush();
stream.Close();
taxTools.csr = csr;
taxTools.Base64csr = Convert.ToBase64String(buffer);
taxTools.typecsr = "Csr";
stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.key", FileMode.Open);
buffer = new byte[stream.Length];
stream.Read(buffer, 0, (int)stream.Length);
string key = Encoding.UTF8.GetString(buffer);
taxTools.key = key;
taxTools.Base64key = Convert.ToBase64String(buffer);
taxTools.typekey = "key";
stream.Flush();
@@ -193,7 +191,6 @@ namespace Back.Services
//});
return new PublicKeyDTO
{
PublicKey = PublicKey,
PublicKeyBase64 = Convert.ToBase64String(buffer),
type = "txt"
};

View File

@@ -8,6 +8,7 @@ namespace Back.Validations
{
public MobileValidation()
{
CascadeMode = CascadeMode.Stop;
RuleFor(m => m)
.NotEmpty().WithMessage("موبایل نمی تواند باشد")
.NotNull().WithMessage("موبایل نمی تواند باشد")