C#->;HttpListener与HTTPS

C#->;HttpListener与HTTPS,c#,http,ubuntu,ssl,https,C#,Http,Ubuntu,Ssl,Https,我用HttpListener创建了一个HTTP服务器,并添加了我的HTTPS前缀 Server = new HttpListener(); Server.Prefixes.Add("https://my.domain.com:8443/"); 在创建服务器之前,我已经添加了以前由Certbot创建的现有证书 X509Certificate2 cert = new X509Certificate2("certificate.pfx"); X509Store

我用HttpListener创建了一个HTTP服务器,并添加了我的HTTPS前缀

Server = new HttpListener();
Server.Prefixes.Add("https://my.domain.com:8443/");
在创建服务器之前,我已经添加了以前由Certbot创建的现有证书

X509Certificate2 cert = new X509Certificate2("certificate.pfx");
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(cert);
服务器加载时没有任何错误,但是当我使用浏览器发出请求时,它不工作

如果我将前缀从“https”更改为“http”,页面将正常加载

我对证书进行了一些调试,似乎是正确的:

store.Certificates.Contains (cert) => True 
cert.GetNameInfo(X509NameType.DnsName, false) => my.domain.com
Certificate.Verify() => True
我还注意到文件夹'/home/ubuntu/.dotnet/corefx/cryptography/x509stores/my'没有生成任何文件,我不知道是否应该生成

Ubuntu:20.04/NetCore:5.0/Tls:1.2/证书:让我们加密(使用私钥转换为PFX)

当我执行wget时,我收到消息:“无法建立SSL连接”

  • 我在使用SslStream类的WebSocket服务器的同一服务器上使用此证书
HttpListener没有加载证书吗?

只是一个问题,您尝试了吗