我有以下错误,当试图使用以下选项连接到服务器上的蚊子代理时,我会得到以下有关私钥的错误,但是我使用服务器crt来验证没有分配私钥的身份验证。
代码:
var serverCertificate = new X509Certificate2("ca.crt");
Debug.WriteLine("+++++" + serverCertificate.HasPrivateKey);
var mqttClient = new MqttFactory().CreateMqttClient();
// Create TCP based options using the builder.
var options = new MqttClientOptionsBuilder()
.WithClientId("foo")
.WithTcpServer("192.168.1.126", 8883)
.WithCredentials("myusername", "mypassword")
//.WithTls(true)
.WithTls(true, false, false, serverCertificate.Export(X509ContentType.Cert))
.WithCleanSession()
.WithProtocolVersion(MqttProtocolVersion.V311)
.WithKeepAlivePeriod(TimeSpan.FromSeconds(60))
.WithCommunicationTimeout(TimeSpan.FromSeconds(30))
.Build();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var connect = await mqttClient.ConnectAsync(options);误差

任何帮助都将不胜感激,谢谢!
发布于 2018-08-09 07:22:44
/data/user/0/com.companyname.name/files里openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfx使用.pfx而不是.crt从本地文件中读取.pfx作为byte[]使用它作为证书
https://stackoverflow.com/questions/51535906
复制相似问题