Search code examples
asp.netapissl-certificateblazor-webassembly

.Net 6 API - can't get data -> ERR_CERT_AUTHORITY_INVALID


I run a .Net 6 API on my Raspberry PI. I can get data from this API using the browser “https://192.168.178.51:7001/swagger/” . Also getting data from entering the url “https://192.168.178.51:7001/api/status/” returns the expected values. So the API is working so far. But when I try to get data from my Blazor WASM App using HTTPClient I get no data. Inspect the browser shows the following message:

GET https://192.168.178.51:7001/api/Status net::ERR_CERT_AUTHORITY_INVALID

How can I fix this? Do I have to install a SSL Certificate? How to do this for a self contained API?


Solution

  • Using a reverse proxy will be the solution, as described here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-6.0

    Quote from the article:

    Kestrel is great for serving dynamic content from ASP.NET Core. However, the web serving capabilities aren't as feature rich as servers such as IIS, Apache, or Nginx. A reverse proxy server can offload work such as serving static content, caching requests, compressing requests, and HTTPS termination from the HTTP server.

    Using a reverse proxy I can set a certificate.