mirror of
https://github.com/MAKS-IT-COM/maksit-certs-ui.git
synced 2025-12-31 12:10:03 +01:00
35 lines
786 B
C#
35 lines
786 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using MaksIT.Webapi.Services;
|
|
|
|
|
|
namespace MaksIT.Webapi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route(".well-known")]
|
|
public class WellKnownController : ControllerBase {
|
|
|
|
private readonly ICertsFlowService _certsFlowService;
|
|
|
|
public WellKnownController(
|
|
IOptions<Configuration> appSettings,
|
|
ICertsFlowService certsFlowService
|
|
) {
|
|
_certsFlowService = certsFlowService;
|
|
}
|
|
|
|
|
|
[HttpGet("acme-challenge/{fileName}")]
|
|
public IActionResult AcmeChallenge(string fileName) {
|
|
var result = _certsFlowService.AcmeChallenge(fileName);
|
|
if (!result.IsSuccess || result.Value == null)
|
|
return NotFound();
|
|
|
|
// Return as plain text, not as JSON
|
|
return Content(result.Value, "text/plain");
|
|
}
|
|
|
|
}
|
|
|