无法识别提供给软件包的凭证:IIS上托管的AWS IoT和WebAPI应用

时间:2019-09-10 06:25:49

标签: c# iis mqtt aws-iot

AWS IoT核心版的证书和策略按照AWS文档是正确的,并且在EC2实例上的控制台应用程序中一切正常。 当在IIS(Web api)上部署相同的代码时,它将引发异常,指出“无法识别提供给程序包的凭据”

      var CaCert = X509Certificate.CreateFromCertFile(Path.Combine(basefolderPath,"IoTCertificates", "AmazonRootCA1.crt"));
      var ClientCert = new X509Certificate2(Path.Combine(basefolderPath, "IoTCertificates", "xxx.pfx"), "xxxxx");

        string ClientId = Guid.NewGuid().ToString();

        var IotClient = new MqttClient(iotendpoint, 8883, true, CaCert, ClientCert, MqttSslProtocols.TLSv1_2);


        IotClient.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
        IotClient.MqttMsgSubscribed += Client_MqttMsgSubscribed;
        IotClient.Connect(ClientId);

        Console.WriteLine("Connected");

错误日志如下:

{“ ClassName”:“ uPLibrary.Networking.M2Mqtt.Exceptions.MqttConnectionException”,“ Message”:“连接到代理的异常”,“ Data”:null,“ InnerException”:{“ NativeErrorCode”:-2146893043, “ ClassName”:“ System.ComponentModel.Win32Exception”,“ Message”:“无法识别提供给软件包的凭据”,“ Data”:null,“ InnerException”:null,“ HelpURL”:null,“ StackTraceString”: “位于System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage,SecureCredential&secureCredential)\ r \ n中。 Net.Security.SecureChannel.AcquireClientCredentials(Byte []&thumbPrint)\ r \ n位于System.Net.Security.SecureChannel.GenerateToken(Byte []输入,Int32偏移量,Int32计数,Byte []和输出)\ r \ n在System.Net.Security.SecureChannel.NextMessage(传入字节[],Int32偏移量,Int32计数)\ r \ n在System.Net.Security.SslState.StartSendBlob (Byte []传入,Int32计数,AsyncProtocolRequest asyncRequest)\ r \ n在System.Net.Security.SslState.ProcessReceivedBlob(Byte []缓冲区,Int32计数,AsyncProtocolRequest asyncRequest)\ r \ n在System.Net.Security.SslState .StartReceiveBlob(Byte []缓冲区,AsyncProtocolRequest asyncRequest)\ r \ n在System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest)\ r \ n在System.Net.Security.SslState.ForceAuthentication(布尔接收第一, Byte []缓冲区,位于System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)的AsyncProtocolRequest asyncRequest)\ r \ n,位于c:\ Users \ ppatierno \中的uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Connect()处Source \ Repos \ m2mqtt \ M2Mqtt \ Net \ MqttNetworkChannel.cs:线266 \ r \ n位于uPLibrary.Networking.M2Mqtt.MqttClient.Connect(String clientId,String username,String password,Boolean willRetain,Byte willQosLevel,Boolean willFlag,String willTopic,字符串willMessage,布尔c leanSession,UInt16 keepAlivePeriod)在c:\ Users \ ppatierno \ Source \ Repos \ m2mqtt \ M2Mqtt \ MqttClient.cs:line 556“,” RemoteStackTraceString“:null,” RemoteStackIndex“:0,” ExceptionMethod“:” 8 \ nAcquireCredentialsHandle \ nSystem版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089 \ nSystem.Net.SSPIWrapper \ nSystem.Net.SafeFreeCredentials AcquireCredentialsHandle(System.Net.SSPIInterface,System.String,System.Net.CredentialUse,System.Net.SecureCredential )“,” HResult“:-2147467259,”源代码“:”系统“,” WatsonBuckets“:null},” HelpURL“:null,” StackTraceString“:”在uPLibrary.Networking.M2Mqtt.MqttClient.Connect(String clientId,字符串用户名,字符串密码,布尔值WillRetain,字节willQosLevel,布尔值willFlag,字符串willTopic,字符串willMessage,布尔值cleanSession,UInt16 keepAlivePeriod)位于c:\ Users \ ppatierno \ Source \ Repos \ m2mqtt \ M2Mqtt \ MqttClient.cs:线560 \ r \ n“,” RemoteStackTraceString“:null,” RemoteStackIndex“:0,” ExceptionMethod“:” 8 \ nConnect \ nM2Mqtt.Net,版本= 4.3.0.0,区域性= neutral,PublicKeyToken = null \ nuPLibrary.Networking.M2Mqtt.MqttClient \ nByte Connect(System.String,System.String,System.String,Boolean,Byte,Boolean,System.String,System.String,Boolean,UInt16)“, “ HResult”:-2146233088,“来源”:“ M2Mqtt.Net”,“ WatsonBuckets”:空}

0 个答案:

没有答案