22 lines
742 B
C#
22 lines
742 B
C#
using back.services.engine.Crypto;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Net;
|
|
|
|
namespace back.controllers;
|
|
|
|
[ApiController, Route("api/[controller]")]
|
|
public class CryptoController(ICryptoService cryptoService) : ControllerBase
|
|
{
|
|
[HttpGet("[action]")] public async Task<IActionResult> RSA([FromHeader(Name = "X-client-thumbprint")] string clientId)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(clientId))
|
|
{
|
|
return BadRequest("Client ID is required.");
|
|
}
|
|
var key = cryptoService.GetPublicCertificate(clientId);
|
|
if (key == null)
|
|
return StatusCode((int)HttpStatusCode.InternalServerError, "Failed to generate RSA keys.");
|
|
return Ok(new { PublicKey = key });
|
|
}
|
|
}
|