im trying to make backend in c# on my linux ubuntu server without using apache2 or ngnix. Everything worked fine, until i've tried to make https, i made a certificate and the key, using openssl copied it to /etc/ssl/certs and /etc/ssl/certs
and i wrote this using different stackoverflow questions:
HttpListener listener = new HttpListener();
string certificatePath = "whoisalmo.crt";
if (!File.Exists(certificatePath))
{
Console.WriteLine($"Cannot find certificate file: {certificatePath}");
return;
}
var certificate = new X509Certificate2(certificatePath);
string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string[] prefixes = { "https://+:443/", "http://*/" };
foreach (string s in prefixes)
listener.Prefixes.Add(s);
listener.Start();
while(true)
{
...
}
when i start this, the http works, but https doesnt, I wont get error in the app but when i try to access the website it says connection was reseted.
i tried
- Making new certificate
- rebooting after coping the crt and key..
- opening firewall on pc and portforwarding on router