尝试连接到代理时,为什么AMQP.Net Lite抛出错误的证书?

时间:2018-12-05 10:17:59

标签: .net ssl .net-core ssl-certificate amqp

我正尝试使用AMQP.Net Lite连接到AMQP代理,如下所示:

ConnectionFactory factory = new ConnectionFactory();        
factory.SSL.ClientCertificates.Add(GetCertificate("my_certificate"));
Connection.DisableServerCertValidation = true;
string address = "amqps://broker_host:5671";
Connection connection = factory.CreateAsync(new Address(address)).Result;

最后一行抛出错误的证书错误,但是,在使用openssl进行连接时,效果很好。

调用堆栈:

Unhandled Exception: System.AggregateException: One or more errors occurred. (Authentication failed, see inner exception.) ---> System.Security.Authentication.AuthenticationException: Authenticationfailed, see inner exception. ---> Interop+AppleCrypto+SslException: misc. bad certificate
   --- End of inner exception stack trace ---
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslState.ThrowIfExceptional()
   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__46_2(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at Amqp.TcpTransport.ConnectAsync(Address address, ConnectionFactory factory)
   at Amqp.ConnectionFactory.CreateAsync(Address address, Open open, OnOpened onOpened)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)

0 个答案:

没有答案