c# - 测试用例在带有 https 的 docker windows 控制台中失败 vstest.console.exe
问题描述
我正在使用带有 Nunit 的 restsharp 运行 API 测试,并且测试用例vstest.console.exe
在 docker windows 中失败,得到“0”作为响应。在本地系统上传递时。
我正在从 docker 容器中访问 https 应用程序。
这是因为 SSL 证书,我用 HTTP 请求验证它按预期工作。
验证我使用的连接
invoke-WebRequest -UseBasicParsing https://hostname
并在容器中收到此错误
invoke-WebRequest :底层连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。
当我使用invoke-WebRequest -UseBasicParsing http://hostname
时,我得到 200 个状态码。
解决方案
此问题与 vstest.console.exe 无关。这个问题是因为 SSL/TLS。由于 CA(证书颁发机构),该容器无法与我的应用程序建立 https 连接。
当我将 CA 导入我的容器时,一切都按预期工作。要导入证书,我使用了 PowerShell 命令
Import-Certificate -FilePath "file.cer" -CertStoreLocation Cert:\\LocalMachine\\Root
推荐阅读
- php - PHP 导出到 csv,估计完成时间或进度条百分比加载
- dart - 如何更新在 dart 中编译的可执行详细信息
- r - 使用 dplyr 对两个变量进行递归求和
- javascript - 每当我导入 bootstrap.bundle.min.js 时,控制台浏览器都会出现问题
- c++ - 在声明后(运行时)创建一个类变量 const(使用一些类方法)
- python-3.x - 从 spark 结构化流写入到 oracle 表的问题
- c - 在 C 中采用可选参数
- google-sheets - 如何根据谷歌表格中的某些条件设置条形图中条形的颜色?
- r - 正则表达式:匹配四位数字的前两位数字
- python - 插入 Django JsonField 而不将内容拉入内存