在没有 Azure IoT 中心的 windows 物联网核心上更新证书
Update certificate on windows iot core without Azure IoT hub
我们有一台 Windows IoT
设备没有互联网连接。我们如何以与 Azure IoT Hub
.
相同的方式更新 SSL
证书
Set up X.509 security in your Azure IoT hub
我们如何在 C# 中执行此操作?
请参考以下代码。CertificateEnrollmentManager 可用于从个人信息交换 (PFX) 消息中导入证书。首先,您需要从 uri 读取远程文件,将缓冲区解析为 base64 字符串,然后将证书导入您的商店。
string pfxCertificate = null;
string pfxPassword = "";
var remoteUri = "http://XXXXXXXX";
IRandomAccessStreamReference thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(remoteUri));
file = await Windows.Storage.StorageFile.CreateStreamedFileFromUriAsync(".pdf",new Uri(remoteUri), thumbnail);
var buffer = await Windows.Storage.FileIO.ReadBufferAsync(file);
using (DataReader dataReader = DataReader.FromBuffer(buffer))
{
byte[] bytes = new byte[buffer.Length];
dataReader.ReadBytes(bytes);
// convert to Base64 for using with ImportPfx
pfxCertificate = System.Convert.ToBase64String(bytes);
}
await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
pfxCertificate,
pfxPassword,
ExportOption.NotExportable,
KeyProtectionLevel.NoConsent,
InstallOptions.None,
"Test");
我们有一台 Windows IoT
设备没有互联网连接。我们如何以与 Azure IoT Hub
.
SSL
证书
Set up X.509 security in your Azure IoT hub
我们如何在 C# 中执行此操作?
请参考以下代码。CertificateEnrollmentManager 可用于从个人信息交换 (PFX) 消息中导入证书。首先,您需要从 uri 读取远程文件,将缓冲区解析为 base64 字符串,然后将证书导入您的商店。
string pfxCertificate = null;
string pfxPassword = "";
var remoteUri = "http://XXXXXXXX";
IRandomAccessStreamReference thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(remoteUri));
file = await Windows.Storage.StorageFile.CreateStreamedFileFromUriAsync(".pdf",new Uri(remoteUri), thumbnail);
var buffer = await Windows.Storage.FileIO.ReadBufferAsync(file);
using (DataReader dataReader = DataReader.FromBuffer(buffer))
{
byte[] bytes = new byte[buffer.Length];
dataReader.ReadBytes(bytes);
// convert to Base64 for using with ImportPfx
pfxCertificate = System.Convert.ToBase64String(bytes);
}
await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
pfxCertificate,
pfxPassword,
ExportOption.NotExportable,
KeyProtectionLevel.NoConsent,
InstallOptions.None,
"Test");