当我将useHttps属性设置为true时,我无法访问服务器。
服务器的实例化如下所示:
class Listener
{
RestServer server;
public Listener()
{
server = new RestServer();
server.Port = "8137";
server.UseHttps = true;
}
}
服务器启动,控制台输入告诉我它在https://localhost:8137上侦听,但是当我尝试发出请求时(在Fiddler中),我收到错误消息:502 Fiddler - Connection Failed。
The connection to 'localhost' failed.
System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https> HTTPS handshake to localhost (for #38) failed. System.IO.IOException Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. < An existing connection was forcibly closed by the remote host
对我来说,看起来HTTPS和证书都有问题。但是我可以在哪里指定证书?
答案 0 :(得分:0)
Grapevine构建于.NET HttpListener
类之上。您从原始帖子中获得的内容足够<代码视角 。但是,还需要在服务器运行的机器上完成更多工作。
请参阅the HttpListener docs,尤其是页面底部的注释。
有一个很好的writeup on StackOverflow用于启用对localhost的https支持。
如果你遇到problems like this one,我会建议在StackOverflow上搜索,因为这个问题与Grapevine无关,而且与证书设置有关。