我正在尝试通过 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/

10-13 02:52