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

Time:10-16

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?

CodePudding user response:

You will need, at minima, a self-sign certificate. Then you will need to let your browser accept a self-sign.(Advance, Proceed to ServerIp)

Now, I do not know what OS you are using in your Raspberry, but for a Beaglebone(similar to Raspberry Pi) with Debian and nginx, here is the procedure

https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-on-debian-10

You will need the same kind of steps for which ever OS and webserver(Apache, nginx...Kestrel?).

CodePudding user response:

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.

  • Related