【问题标题】:MSDeploy API - Allow Untrusted CertificateMSDeploy API - 允许不受信任的证书
【发布时间】:2012-10-11 08:26:02
【问题描述】:

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

【问题讨论】:

    标签: msdeploy webdeploy microsoft-web-deploy


    【解决方案1】:

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

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

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

    【讨论】:

    • 这是 msdeploy.exe 在处理-allowUntrustedCertificate 时所做的,因此绝对是正确的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-13
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 2010-11-15
    • 2012-07-05
    相关资源
    最近更新 更多