松弛通知程序在章鱼部署中失败

问题描述 投票:1回答:2

我们已经为我们的应用程序配置了Octopus部署。成功部署后,我们将在松弛状态下发送有关部署状态的通知。

However this steps is failing since last few days but I am not able to find out root cause of it.

We are getting below error:
______________________________________________________________________________


Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.

+     Invoke-RestMethod -Method POST -Body ($payload | ConvertTo-Json - ...

Error
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException+ FullyQualifiedError IdWebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

The remote script failed with exit code 1

______________________________________________________________________________






We have verified tls version on server.
We have referred few articles from net to bypass ssl or tls validation.

Powershell Script we are using
_____________________________________________________________________________

[[Net.ServicePointManager] :: SecurityProtocol = [Net.SecurityProtocolType] :: Tls12

Invoke-RestMethod -Method POST -Body($ payload | ConvertTo-Json -Depth 4)-Uri $ OctopusParameters ['HookUrl'] -ContentType'application / json'}

powershell slack-api octopus-deploy
2个回答
0
投票

我用下面的代码更新模板,更新项目步骤,并且成功了。

 add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
"@




[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3, [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12

Invoke-RestMethod -Method POST -Body ($payload | ConvertTo-Json -Depth 4) -Uri $OctopusParameters['HookUrl']  -ContentType 'application/json'

0
投票

我只需要在我的PowerShell Slack通知脚本中的现有Invoke-RestMethod行之前立即插入以下行,即可使工作再次正常:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

请参阅此相关答案以获取有关此处发生的情况的更多详细信息:https://stackoverflow.com/a/45692875/12484

© www.soinside.com 2019 - 2024. All rights reserved.