Webquery HTTPS SSL Authority invalid

Hello, I have successfully installed the SSL certificate to use HTTPS Query but every time I try to connect it returns net::ERR_CERT_AUTHORITY_INVALID.
I have also tried to copy the SSL certificate from my letsencrypt folder or to include them with the full path but got no victory with it.

So I tried this command again
openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365
and sadly got that answer above.

I am trying to solve it the second day and I ran out of ideas.
Every answer would be helpful!

EDIT: Maybe it is important, maybe it is not. I am sending POST request via JQuery $.post.

Your cert is missing a AUTHORITY Entry.

Or you are connecting to the wrong domain.

How do I add an Authority entry?
I also made a copy of the ssl certificate that is saved in /etc/letsencrypt/live/occamy.cz/cert.pem and privkey.pem so there should be no problem with a wrong domain but there is still the same error.

Those certificates are running SSL on my domain without a problem.

Okay, so I tried some magic and now my problem is this

net::ERR_CERT_COMMON_NAME_INVALID

So… It kind of works now. I am still using a self-signed certificate but I turned off checking the SSL certificate.

$url = "https://localhost:10443/1/serverinfo?api-key=apikey";
  
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  
$headers = array(
"Accept: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

If someone could tell me how to generate a certificate that is not self-signed or there is no CERT_COMMON_NAME_INVALID, I would be very thankful!