小编Har*_*h R的帖子

是否有任何开源 OPC UA 服务器,我可以在其中添加和配置 FileType 节点

我正在开发一个 OPC UA 客户端应用程序,它读取存储在 OPC UA 服务器上的文件。出于测试目的,我需要一个 OPC UA 服务器模拟器,我可以在其中添加 FileType 节点并配置这些节点。

目前我正在使用 Prosys OPC UA 服务器模拟器,我可以在其中添加变量类型的节点,但不能添加文件类型的节点。

在此处输入图片说明

opc-ua

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

为什么我在下载文件时收到错误“错误 [ERR_STREAM_WRITE_AFTER_END]:结束后写入”?

我正在尝试使用各个 blob 的 url 下载存储在 azure blob 存储中的文件。

我正在下载五个 blob 文件,并且我确实有所有这些 blob 文件的单独 URL。

下面是我的代码:

function Download()
{
  const fs = require('fs');
  const path = require('path');
  const https = require('https');
  const url = require('url');

  var sasToken = '?sv=2019-02-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2019-10-3xxxxxxxZ&sp=rl'
  var blobUris = ['https:xxx', 'xxx', 'xxx', 'xxx', 'xxx'];

  var i;
  for(i=0; i<blobUris.length; i++)
  {
    var sasUrl = blobUris[i] + sasToken;
    var filename=url.parse(blobUris[i]).pathname.split('/').pop();
    var filePath = "D:/BLESensor"
    var file = fs.createWriteStream(filePath+"/"+filename)
    var request = https.get(sasUrl, function(response) {
      response.pipe(file);
        //  Promise.resolve()
        //  .then(() => …
Run Code Online (Sandbox Code Playgroud)

javascript http download node.js

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

解密文件时出现异常“密钥在指定状态下无效”

我正在生成一个证书并将该证书加密为本地磁盘的 bin 文件。我正在使用以下 powershell 代码执行此操作:

$bytes = $CertificateResponse.ToCharArray() | % {[byte] $_}
[Byte[]]$entropy = 4,17,9,88,236,1688,1486,41,182,16,72,93,2,188,2,23

# Encrypt the byte array.
$encryptedBytes = [System.Security.Cryptography.ProtectedData]::Protect(
        $bytes, 
        $entropy, 
        [System.Security.Cryptography.DataProtectionScope]::LocalMachine)

$encryptedBytes | Set-Content C:\certificate\xxx.bin -Encoding Byte

Run Code Online (Sandbox Code Playgroud)

后来相同的二进制文件保存在其他机器上,我正在尝试按如下方式读取和解密文件(使用 c#):

 try
            {
                this.EntropyKey = new byte[] { 4,17,9,88,236,1688,1486,41,182,16,72,93,2,188,2,23};
                var data = File.ReadAllBytes(Path.Combine(localPath, "xxx.bin"));
                var decryptedData = ProtectedData.Unprotect(data, this.EntropyKey, DataProtectionScope.LocalMachine);
                this.Certificate = new X509Certificate(decryptedData);
                return Task.CompletedTask;
            }
            catch (Exception ex)
            {
                throw new NotImplementedException();
            }

Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我在尝试解密的行中收到异常为“密钥在指定状态下无效”。如果我尝试使用 powershell 命令解密,它工作正常。任何帮助将非常感激。注意:我已授予该文件的读取权限。

c# powershell cryptography x509certificate

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