【问题标题】:Azure Blob Storage : unable to verify the first certificateAzure Blob 存储:无法验证第一个证书
【发布时间】:2020-05-01 01:13:06
【问题描述】:

我创建了一个新的 Azure 存储帐户。在其中我有一个 blob 容器,其访问类型设置为“私有”。以下是我尝试创建容器的 nodejs 代码。

var azure = require('azure-storage');              
            var accountName = "xxxxxxxxxx";
            var accessKey = "veryLongAccessKey";
            var host = "https://abc.blob.core.windows.net";
            var blobSvc = azure.createBlobService(accountName, accessKey, host);

            blobSvc.createContainerIfNotExists('myblobContainer', function(error, result, response) {
                console.log("error");
                console.log(error);
                console.log("result");
                console.log(result);
                console.log("response");
                console.log(response);
            });

当我执行此代码时,出现以下错误。

{ Error: unable to verify the first certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1062:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:586:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

我错过了什么?

【问题讨论】:

  • 我用我的一个存储帐户尝试了您的代码,但无法重现错误。你能分享更多细节吗?比如你使用的是什么版本的 Node SDK?图片中是否有代理/防火墙?您是否自定义了节点设置?
  • 节点 6.9.1。没有防火墙。我没有做任何特殊的节点设置。上面的代码是否创建了一个blob容器?
  • 问题出在主机名中的 httpS。我放了http。
  • 如果使用http,响应可以被中间任何第三方拦截。我强烈建议您修复证书问题,并使用 HTTPS。

标签: node.js azure


【解决方案1】:
openssl s_client -connect {StorageAccount}.blob.core.windows.net:443 \
                 -servername {StorageAccount}.blob.core.windows.net

说:

Certificate chain

 0 s:/CN=*.blob.core.windows.net
   i:/C=US/ST=Washington/L=Redmond/O=Microsoft Corporation
     /OU=Microsoft IT/CN=Microsoft IT SSL SHA2

 1 s:/C=US/ST=Washington/L=Redmond/O=Microsoft Corporation
     /OU=Microsoft IT/CN=Microsoft IT SSL SHA2
   i:/C=IE/O=Baltimore/OU=CyberTrust/CN=Baltimore CyberTrust Root

您可能缺少巴尔的摩根 CA。

可能的原因:

  • 节点的 CA 包中缺少证书,链验证失败。不熟悉 Node 如何处理其 CA 包,但值得研究

  • 您的 TLS 中有一些东西(Fiddler 或其他一些中间人 TLSinspector

可以在here 找到使用ssl-root-cas 的解决方法(如果您无法追踪根本原因)。

【讨论】:

    【解决方案2】:

    我在尝试从我公司的网络(防火墙和代理)连接到 Azure 存储 blob 时遇到了一些关于 SSL 验证的问题,我尝试关闭 SSL 验证并且它成功了。

    const myRequest = require('request').defaults({strictSSL: false})
    

    不要忘记在最后重新启用它。 虽然这暂时有效,但它是一种变通方法/脏修复,而不是解决方案。

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 2021-01-02
      • 2020-02-17
      • 2021-03-26
      • 1970-01-01
      • 2018-08-29
      • 2020-03-29
      • 2021-06-15
      • 1970-01-01
      相关资源
      最近更新 更多