4

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

4

1 回答 1

6

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

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

ServicePointManager.ServerCertificateValidationCallback = (s, c, chain, err) =>
{
    return true;
};
于 2012-10-21T08:03:45.380 回答