gpt4 book ai didi

MSDeploy API - 允许不受信任的证书

转载 作者:行者123 更新时间:2023-12-05 00:32:45 25 4
gpt4 key购买 nike

我正在尝试通过 c# 使用 MSDeploy API 运行远程 MSDeploy 命令。

我正在运行以下内容:

//test connection by pulling down file list
var sourceBaseOptions = new DeploymentBaseOptions();
var destBaseOptions = new DeploymentBaseOptions
{
ComputerName = "https://mysite.com/msdeploy.axd?sitename=siteName",
UserName = "username",
Password = "password",
AuthenticationType = "Basic"
};
var syncOptions = new DeploymentSyncOptions();

var deployment = DeploymentManager.AvailableProviderFactories;
DeploymentObject deploymentObject = DeploymentManager.CreateObject("dirPath", Settings.TemporaryStoragePath, sourceBaseOptions);
// collect and report all the changes that would happen
var changes = deploymentObject.SyncTo(destBaseOptions, syncOptions);

当我运行不受信任的证书时,它会引发异常。我如何告诉 MSDeploy 不要担心证书? (即基于“AllowUntrustedCertificate=true”的代码)

最佳答案

看来我必须设置 ServicePointManager回调服务器证书验证。

在我调用 MSDeploy 之前放置以下内容似乎有效:

ServicePointManager.ServerCertificateValidationCallback = (s, c, chain, err) =>
{
return true;
};

关于MSDeploy API - 允许不受信任的证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12995991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com