小编Spa*_*ark的帖子

在 C# 代码中包含 CA 证书

我想将 CA 证书包含在资源文件 (Resources.resx) 中,并且一旦作为字节流读取,就会提供给 X509Certificate 构造函数类。CA 证书采用 .der 格式。我已将 .der 文件添加到项目的 Resources 文件夹中。如何在另一个类中访问它并将其传递给 X509Certificate 构造函数?

我遵循此链接底部给出的 C# 代码 [ http://www.embedded101.com/Blogs/PaoloPatierno/entryid/366/mqtt-over-ssl-tls-with-the-m2mqtt-library-and-蚊子经纪人]

更新:这是我在客户端所做的方式。

    client = new MqttClient(ddlServerIP.Text, MqttSettings.MQTT_BROKER_DEFAULT_SSL_PORT, true, new X509Certificate(Properties.Resources.ca)
           , new X509Certificate(Properties.Resources.client2), MqttSslProtocols.TLSv1_2);   
        String clientId= Guid.NewGuid().ToString();
        byte code = client.Connect(clientId);
Run Code Online (Sandbox Code Playgroud)

然而在服务器端我收到一个错误:

OpenSSL 错误:错误:140890C7:SSL 例程:SSL3_GET_CLIENT_CERTIFICATE:对等方未返回证书

c# resx ca x509certificate

1
推荐指数
1
解决办法
5591
查看次数

标签 统计

c# ×1

ca ×1

resx ×1

x509certificate ×1