加密出现:DSO support routines:win32_load:could not load the shared library

淦,今天终于把这个问题解决了,之前一直很奇怪的bug,只要在window系统上涉及到加密这一块,总会出现这个问题,例如crypto,微信支付,支付宝支付..google也找不到任何答案,但在部署到linux上就没问题,所以后面操作都是同步到服务器上进行修改,这次又遇到这个问题就想给他解决掉。

错误信息:

Error: error:25078067:DSO support routines:win32_load:could not load the shared library
    at Sign.sign (node:internal/crypto/sig:131:29)
    at Object.sign (项目路径\node_modules\alipay-sdk\lib\util.js:94:34)
    at AlipaySdk.pageExec (项目路径\node_modules\alipay-sdk\lib\alipay.js:168:33)
    at AlipaySdk.exec (项目路径\node_modules\alipay-sdk\lib\alipay.js:263:25)
    at createOrder (项目路径\createOrder.js:46:37)
    at asyncCreate (项目路径\server.js:47:30)
    at 项目路径\server.js:50:5
    at Layer.handle [as handle_request] (项目路径\node_modules\express\lib\router\layer.js:95:5)
    at next (项目路径\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (项目路径\node_modules\express\lib\router\route.js:112:3) {
  opensslErrorStack: [
    'error:0E076071:configuration file routines:module_run:unknown module name',
    'error:0E07506E:configuration file routines:module_load_dso:error loading dso',
    'error:25070067:DSO support routines:DSO_load:could not load the shared library'
  ],
  library: 'DSO support routines',
  function: 'win32_load',
  reason: 'could not load the shared library',
  code: 'ERR_OSSL_DSO_COULD_NOT_LOAD_THE_SHARED_LIBRARY'
}

为何发生错误:
因为我早期需要打包密钥文件,从官网下载了openssl的安装包进行安装,但后面没用到了,就扔在那了,也没去卸载

因为接入的支付宝和微信支付都会用到crypto这个库,这个库会调用系统的openssl进行编译?但我自行安装的可能有点问题或者就是无法版本不对,导致无法调用。

解决方法:

  1. 如果系统上已经有安装了openssl,如何判断已经有安装?卸载掉,或者删除系统环境变量(找到openssl)
  2. 安装git(一般程序员系统都自带这个了,可忽略)
  3. 添加系统环境变量(Path)
git的安装目录\usr\bin 例如:D:\System\Git\usr\bin

测试命令操作符窗口中输入openssl,查看是否可以使用

这样就可以了,这样我们就是直接调用git自带的openssl,就不用自己手动安装,免得出各种问题。如果也能帮到你的话,记得赏我杯咖啡...

参考资料:
ssl - How to install OpenSSL in windows 10? - Stack Overflow

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

相关阅读更多精彩内容

友情链接更多精彩内容