- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用自定义自签名证书测试 signalr .net 客户端时遇到了一些异常。
http上也不异常(exception)。
在我的代码中设置自签名证书有什么问题吗?
请注意,我的证书文件没有问题,因为它可以很好地运行我的 https mvc 站点。
服务器端代码:asp.net, azure local fabric
[assembly: OwinStartup(typeof(BookohWebRole.Startup))]
namespace BookohWebRole
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
hubConfiguration.EnableJavaScriptProxies = false;
//GlobalHost.HubPipeline.AddModule(new ErrorHandlingPipelineModule());
app.MapSignalR(hubConfiguration);
}
}
}
public class ChatHub : Hub
{
public override Task OnConnected()
{
Trace.TraceInformation("OnConnected");
var authToken = Context.QueryString.Get("AuthToken");
Trace.TraceInformation("authToken : " + authToken);
return base.OnConnected();
}
public override Task OnDisconnected(bool stopCalled)
{
Trace.TraceInformation("OnDisconnected");
return base.OnDisconnected(stopCalled);
}
public override Task OnReconnected()
{
Trace.TraceInformation("OnReconnected");
var authToken = Context.QueryString.Get("AuthToken");
Trace.TraceInformation("authToken : " + authToken);
return base.OnReconnected();
}
public void Send(string name, string message)
{
Trace.TraceInformation("Context.ConnectionId : " + Context.ConnectionId);
Clients.All.onSend(name, message);
}
}
客户端代码:.net客户端,单元测试方法
[TestMethod]
public void chat()
{
var ev = new AutoResetEvent(false);
Task.Run(async () =>
{
try
{
ServicePointManager.DefaultConnectionLimit = 10;
var queryString = new Dictionary<string, string>();
queryString.Add("AuthToken", Guid.NewGuid().ToString());
//https://localhost:44302/
//http://localhost:22792/
var hubConnection = new HubConnection("https://localhost:44302/");
hubConnection.Credentials = CredentialCache.DefaultCredentials;
hubConnection.AddClientCertificate(X509Certificate.CreateFromCertFile("bookoh.cer"));
hubConnection.TraceLevel = TraceLevels.All;
hubConnection.TraceWriter = Console.Out;
IHubProxy chatHubProxy = hubConnection.CreateHubProxy("ChatHub");
await hubConnection.Start();
chatHubProxy.On<string, string>("onSend", (name, message) =>
{
Trace.TraceInformation("onSend name : " + name);
Trace.TraceInformation("onSend message : " + message);
ev.Set();
});
Trace.TraceInformation("chatHubProxy.Invoke");
await chatHubProxy.Invoke("Send", "hhd2002", "hello");
}
catch (Exception ex)
{
Trace.TraceInformation("ex : " + ex);
}
});
ev.WaitOne();
}
客户端程序的完整异常信息
vstest.executionengine.x86.exe Information: 0 : ex : System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
最佳答案
看起来您的实际异常消息是
The remote certificate is invalid according to the validation procedure.
这很可能是因为它是自签名的,而不是由受信任的证书颁发机构签名的。看起来这里已经回答了这个问题:
关于asp.net - "Could not establish trust relationship for the SSL/TLS secure channel."signalr2.2、https、.net 客户端、自定义证书异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29957268/
我最近开始使用 MSpec,将类分为 Establish、Because 和 It。 虽然我知道如何使用它们,但我不确定是什么让它们起作用。 我知道他们是代表 Because of = () => {
我的理解是每个 Establish 应该只执行一次,但下面的代码显示它执行了多次。我们嵌套类以提供一些分组,同时将 Subject 的单元测试保留在一个文件中。这似乎是一个错误。 我们正在使用 mac
我一直在谷歌上广泛搜索,试图解决这个问题,但似乎找不到解决方案。我正在尝试在我的 Chrome 扩展程序中完成设置监听器和发送器的简单任务。 我的 list { "manifest_version
这个错误是我从 lastError.js 文件中得到的,我没有在我的 html 页面中调用它。 var errorMessage = name + ': ' + message; if (sta
我的一个 AMQ 生产者有问题,我有网络问题,因此它无法向 Q 发送消息。然而,服务器打开与 Q 机器的连接并保持它们完好无损。连接数增加,Q 机器窒息,无法为其其余生产者和消费者提供服务。 这是我在
尝试从弹出窗口向我的 contentscript 发送消息时出现此错误。我想要做的是从我的 content.js 获取当前选项卡的文档并将其发送到弹出窗口。我该如何解决这个错误? { "manif
我有一个 Java 网络爬虫。我注意到,对于我抓取的少量服务器,我留下了大量已建立的套接字: joel@bohr:~/tmp/test$ lsof -p 6760 | grep TCP java
我正在使用 Unitt 库 ( http://code.google.com/p/unitt/wiki/UnittWebSocketClient ) 尝试在我的 iOS (iPhone) 应用程序中通
我正在使用 EWS Java API 连接 Exchange 服务器并检索有关邮件、日历约会和任务的信息。 除一个帐户外,它适用于许多用户。我收到以下错误: microsoft.exchange.we
我想使用 C/C++ 获取到我的服务器的 SYN 和 ESTABLISHED 连接数。但我不想调用 popen 来运行 netstat 或任何其他 Linux 命令。我设法扫描了/proc/net/i
我正在测试应用程序尝试访问未知 URL 时的行为。引发 ConnectionError 需要 5 秒。我怎样才能修改为在 100 毫秒时失败? 我尝试使用 requests.get(url, time
当我尝试为我的 VpnService 创建隧道接口(interface)时,出现以下错误: Attempt to invoke virtual method 'java.lang.String and
如果有一个网络服务器在端口 80 上运行,并且有人使用随机分配的端口 x 从客户端连接,那么服务器知道要回复哪个端口。但是,从那时起,与服务器的通信是否从那时起继续在端口 80 上进行(将文件描述符分
我做了一个实验: 一个监听8804端口的服务器接受一个客户端的连接,然后无休止地向客户端发送数据。我关闭了网络。 当我运行 netstat -anotp | grep 8804 ,显示服务器和客户端的
我正在尝试使用 JSch通过 ssh 连接到我的计算机,然后运行命令。 但是,当我运行代码时,我从未连接到计算机。和以下错误: I/System.out: com.jcraft.jsch.JSchEx
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
尝试为我们的Intranet的Web服务站点设置一个自签名证书。证书本身表明它是“ok”,但是当尝试从Web服务调用方法时,它会引发错误,并且在添加Web引用时也会给出警告。 这是确保我提供准确信息的
我正在使用 JavaScript 和 Union platform我将如何诊断这个问题?非常感谢。 最佳答案 如果你去http://jsbin.com/ekusep/6/edit并查看 JavaScr
我正在尝试设置一个保存点,并在遇到问题时回滚到该点。但我收到以下消息: SQL execution error, ORA-01086: savepoint 'LASTSAVE' never estab
我只有一个托管对象上下文。 不过我已经修改了托管对象存储。 我想将某些字段添加到每个托管对象中。将它们一一添加到系统中的每个对象会花费太多时间,因此我决定以编程方式将它们添加到托管对象模型中。在应用程
我是一名优秀的程序员,十分优秀!